AccountingNext/Schaad.Accounting.Tests/WaterBillTestShould.cs
Claudio Schaad 1e9e19ebad Add "Wasser" page for the water bills
Same layout as the Strom page: grid and dialog for the bills (warm and
cold water in m3 and CHF, base costs; total m3 and CHF are computed),
stored per mandator in water.json, and charts for consumption and total
costs with the period toggle (bill, calendar year, half-year).

The period grouping is now generic: ElectricityPeriod becomes
BillPeriod<T> over IPeriodBill<T>, implemented by ElectricityBill and
WaterBill. water.json can be edited in the JSON editor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 20:56:18 +01:00

53 lines
1.5 KiB
C#

using Schaad.Accounting.Models;
using Shouldly;
namespace Schaad.Accounting.Tests;
public class WaterBillTestShould
{
[Fact]
public void AddWarmAndColdWaterWhenCalculatingTotalM3()
{
var bill = new WaterBill { WarmWaterM3 = 12.345m, ColdWaterM3 = 30.5m };
bill.TotalM3.ShouldBe(42.845m);
}
[Fact]
public void DivideWarmWaterByTotalWhenCalculatingWarmWaterShare()
{
var bill = new WaterBill { WarmWaterM3 = 10m, ColdWaterM3 = 30m };
bill.WarmWaterShare.ShouldBe(0.25m);
}
[Fact]
public void ReturnZeroWarmWaterShareWhenThereIsNoConsumption()
{
var bill = new WaterBill { WarmWaterM3 = 0m, ColdWaterM3 = 0m };
bill.WarmWaterShare.ShouldBe(0m);
}
[Fact]
public void AddWarmColdAndBaseCostsWhenCalculatingTotalChf()
{
var bill = new WaterBill { WarmWaterChf = 250.40m, ColdWaterChf = 98.15m, BaseCostsChf = 120m };
bill.TotalChf.ShouldBe(468.55m);
}
[Fact]
public void AddShareOfAllValuesWhenAddingShareOfOtherBill()
{
var sum = new WaterBill { WarmWaterM3 = 1m, ColdWaterM3 = 2m, WarmWaterChf = 4m, ColdWaterChf = 5m, BaseCostsChf = 3m };
sum.AddShare(new WaterBill { WarmWaterM3 = 10m, ColdWaterM3 = 20m, WarmWaterChf = 40m, ColdWaterChf = 50m, BaseCostsChf = 300m }, 0.5m);
sum.WarmWaterM3.ShouldBe(6m);
sum.ColdWaterM3.ShouldBe(12m);
sum.WarmWaterChf.ShouldBe(24m);
sum.ColdWaterChf.ShouldBe(30m);
sum.BaseCostsChf.ShouldBe(153m);
}
}