Preisrechner: Rappenrundung im Backend und Rabatt-Rechner im Web
agentd task ad07191c406d4ea496b0b18db826651e
This commit is contained in:
@@ -33,4 +33,25 @@ public sealed class PriceCalculatorTests
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => PriceCalculator.ApplyDiscount(100m, 101m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDiscount_99_90_with_10_percent_rounds_to_89_90()
|
||||
{
|
||||
// 99.90 * (1 - 10/100) = 89.91 → rounded to nearest 0.05 = 89.90
|
||||
Assert.Equal(89.90m, PriceCalculator.ApplyDiscount(99.90m, 10m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDiscount_10_with_33_percent_rounds_correctly()
|
||||
{
|
||||
// 10 * (1 - 33/100) = 6.70 → 6.70 is already a multiple of 0.05
|
||||
Assert.Equal(6.70m, PriceCalculator.ApplyDiscount(10m, 33m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDiscount_5_55_with_10_percent_rounds_to_5_00()
|
||||
{
|
||||
// 5.55 * 0.9 = 4.995 → rounded to nearest 0.05 = 5.00
|
||||
Assert.Equal(5.00m, PriceCalculator.ApplyDiscount(5.55m, 10m));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user