Co-authored-by: Claudio Schaad <c.schaad@pog.ch> Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using Schaad.Accounting.Models;
|
|
using Shouldly;
|
|
|
|
namespace Schaad.Accounting.Tests;
|
|
|
|
public class ElectricityBillTestShould
|
|
{
|
|
[Fact]
|
|
public void AddGridAndPvWhenCalculatingTotalKwh()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 3419.432m, PvKwh = 1936.328m };
|
|
|
|
bill.TotalKwh.ShouldBe(5355.76m);
|
|
}
|
|
|
|
[Fact]
|
|
public void DividePvByTotalWhenCalculatingPvShare()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 600m, PvKwh = 400m };
|
|
|
|
bill.PvShare.ShouldBe(0.4m);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnZeroPvShareWhenThereIsNoConsumption()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 0m, PvKwh = 0m };
|
|
|
|
bill.PvShare.ShouldBe(0m);
|
|
}
|
|
|
|
[Fact]
|
|
public void AddGridPvAndSideCostsWhenCalculatingTotalChf()
|
|
{
|
|
var bill = new ElectricityBill { GridChf = 1009.55m, PvChf = 544.10m, SideCostsChf = 134.30m };
|
|
|
|
bill.TotalChf.ShouldBe(1687.95m);
|
|
}
|
|
|
|
[Fact]
|
|
public void DivideTotalChfByTotalKwhWhenCalculatingChfPerKwh()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 600m, PvKwh = 400m, GridChf = 60m, PvChf = 40m };
|
|
|
|
bill.ChfPerKwh.ShouldBe(0.1m);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnZeroChfPerKwhWhenThereIsNoConsumption()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 0m, PvKwh = 0m, GridChf = 0m, PvChf = 0m, SideCostsChf = 50m };
|
|
|
|
bill.ChfPerKwh.ShouldBe(0m);
|
|
}
|
|
|
|
[Fact]
|
|
public void DivideGridChfByGridKwhWhenCalculatingGridChfPerKwh()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 600m, GridChf = 180m };
|
|
|
|
bill.GridChfPerKwh.ShouldBe(0.3m);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnNullGridChfPerKwhWhenThereWasNoGridDraw()
|
|
{
|
|
var bill = new ElectricityBill { GridKwh = 0m, GridChf = 0m };
|
|
|
|
bill.GridChfPerKwh.ShouldBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void DividePvChfByPvKwhWhenCalculatingPvChfPerKwh()
|
|
{
|
|
var bill = new ElectricityBill { PvKwh = 400m, PvChf = 100m };
|
|
|
|
bill.PvChfPerKwh.ShouldBe(0.25m);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnNullPvChfPerKwhWhenThereWasNoPvConsumption()
|
|
{
|
|
var bill = new ElectricityBill { PvKwh = 0m, PvChf = 0m };
|
|
|
|
bill.PvChfPerKwh.ShouldBeNull();
|
|
}
|
|
}
|