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,36 @@
using Xunit;
namespace Prices.Tests;
public sealed class PriceCalculatorTests
{
[Fact]
public void No_discount_keeps_the_price()
{
Assert.Equal(100m, PriceCalculator.ApplyDiscount(100m, 0m));
}
[Fact]
public void A_full_discount_makes_it_free()
{
Assert.Equal(0m, PriceCalculator.ApplyDiscount(200m, 100m));
}
[Fact]
public void A_quarter_off_200_is_150()
{
Assert.Equal(150m, PriceCalculator.ApplyDiscount(200m, 25m));
}
[Fact]
public void Half_off_80_is_40()
{
Assert.Equal(40m, PriceCalculator.ApplyDiscount(80m, 50m));
}
[Fact]
public void A_discount_above_100_percent_is_refused()
{
Assert.Throws<ArgumentOutOfRangeException>(() => PriceCalculator.ApplyDiscount(100m, 101m));
}
}