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:
36
tests/Prices.Tests/PriceCalculatorTests.cs
Normal file
36
tests/Prices.Tests/PriceCalculatorTests.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user