Seed: price calculator with discount tests

Mini project for agentd live testing: three of the five tests fail on main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Honegger, Florian
2026-08-05 00:40:48 +02:00
parent afb08a56a2
commit 3f086f9dca
6 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
namespace Prices;
/// <summary>Turns a list price into what the customer actually pays.</summary>
public static class PriceCalculator
{
/// <summary>Applies a percentage discount to a price, e.g. 25 for a quarter off.</summary>
public static decimal ApplyDiscount(decimal price, decimal discountPercent)
{
if (price < 0)
{
throw new ArgumentOutOfRangeException(nameof(price), "A price cannot be negative.");
}
if (discountPercent is < 0 or > 100)
{
throw new ArgumentOutOfRangeException(nameof(discountPercent), "A discount is between 0 and 100 percent.");
}
return price - discountPercent;
}
}

9
src/Prices/Prices.csproj Normal file
View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>