public void ConsumptionsWithEqualValueShouldBeEqual(int value) { Consumption first = Consumption.Create(value); Consumption second = Consumption.Create(value); Assert.That(first, Is.EqualTo(second)); }
public void ConsumptionWithDifferentValueShouldNotBeEqual(int firstValue, int secondValue) { Consumption first = Consumption.Create(firstValue); Consumption second = Consumption.Create(secondValue); Assert.That(first, Is.Not.EqualTo(second)); }
public void ConsumptionsWithEqualValueShouldHaveEqualHashCode(int value) { Consumption first = Consumption.Create(value); Consumption second = Consumption.Create(value); Assert.That(first.GetHashCode(), Is.EqualTo( second.GetHashCode())); }
public void ConsumptionsWithDifferentValueShouldHaveDifferentHashCode( int firstValue, int secondValue) { Consumption first = Consumption.Create(firstValue); Consumption second = Consumption.Create(secondValue); Assert.That(first.GetHashCode(), Is.Not.EqualTo( second.GetHashCode())); }
public static Consumption ToConsumption(this string input) { if (!int.TryParse(input, out int consumptionValue)) { throw new ArgumentException("Invalid format for consumption", nameof(input)); } return(Consumption.Create(consumptionValue)); }
public void ShouldSubtractConsumptionsCorrectly(int firstValue, int secondValue, int expectedValue) { Consumption first = Consumption.Create(firstValue); Consumption second = Consumption.Create(secondValue); Consumption expected = Consumption.Create(expectedValue); Consumption actual = first - second; Assert.That(expected, Is.EqualTo(actual)); }
public void ShouldCalculateYearlyCostCorrectly(int consumptionValue, decimal expectedCostValue) { Consumption consumption = Consumption.Create(consumptionValue); BasicElectricityTariffCalculation calculation = new BasicElectricityTariffCalculation(); ConsumptionCost expectedCost = ConsumptionCost.Create(expectedCostValue); ConsumptionCost actualCost = calculation.Calculate(consumption); Assert.That(expectedCost, Is.EqualTo(actualCost)); }
public void ShouldReturnZeroConsumptionWhenSubtractingEqualConsumptions() { const int consumptionValue = 1000; Consumption first = Consumption.Create(consumptionValue); Consumption second = Consumption.Create(consumptionValue); Consumption expected = Consumption.ZERO; Consumption actual = first - second; Assert.That(expected, Is.EqualTo(actual)); }
public void ShouldCalculateYearlyCostsCorrectly(int consumptionValue, decimal expectedCostValue) { PackagedTariffHighConsumptionCalculation calculation = new PackagedTariffHighConsumptionCalculation(); ConsumptionCost expectedCost = ConsumptionCost.Create(expectedCostValue); Consumption consumption = Consumption.Create(consumptionValue); ConsumptionCost actualCost = calculation.Calculate(consumption); Assert.That(expectedCost, Is.EqualTo(actualCost)); }
public void ShouldCreateConsumptionForValidValue(int validValue) { Consumption consumption = Consumption.Create(validValue); Assert.That(consumption, Is.Not.Null); }
public void ShouldNotCreateConsumptionForInvalidValue(int invalidValue) { Assert.Throws <ArgumentException>(() => Consumption.Create(invalidValue)); }