Preisrechner: Rappenrundung im Backend und Rabatt-Rechner im Web

agentd task 332cb3ed956546778f775e25fa01f8c3
This commit is contained in:
agentd
2026-08-05 01:11:56 +00:00
parent 605a952f7a
commit 8c1147f2a0
8 changed files with 220 additions and 5 deletions

View File

@@ -33,4 +33,25 @@ public sealed class PriceCalculatorTests
{
Assert.Throws<ArgumentOutOfRangeException>(() => PriceCalculator.ApplyDiscount(100m, 101m));
}
}
[Fact]
public void Swiss_rappernrundung_rounds_to_nearest_0_05()
{
// 99.90 * 0.9 = 89.91 → 89.91 * 20 = 1798.2 → round to 1798 → 1798 / 20 = 89.90
Assert.Equal(89.90m, PriceCalculator.ApplyDiscount(99.90m, 10m));
}
[Fact]
public void Rounding_rounds_down_when_cent_remainder_is_below_0_05()
{
// 1.23 * 0.5 = 0.615 → 0.615 * 20 = 12.3 → round to 12 → 12 / 20 = 0.60
Assert.Equal(0.60m, PriceCalculator.ApplyDiscount(1.23m, 50m));
}
[Fact]
public void Rounding_rounds_up_when_cent_remainder_is_at_0_05()
{
// 3.37 * 0.5 = 1.685 → 1.685 * 20 = 33.7 → round to 34 → 34 / 20 = 1.70
Assert.Equal(1.70m, PriceCalculator.ApplyDiscount(3.37m, 50m));
}
}