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));
|
||||
}
|
||||
}
|
||||
20
tests/Prices.Tests/Prices.Tests.csproj
Normal file
20
tests/Prices.Tests/Prices.Tests.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Prices\Prices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user