public void CalculateAnnualCosts(double consumption)
        {
            if (consumption < 0)
            {
                throw new ArgumentException("Argument should not be less than zero", nameof(consumption));
            }

            IAnnualCostsCalculationStrategy annualCostsCalculationStrategy;

            switch (Name)
            {
            case TariffConstants.BasicTariffName:
                annualCostsCalculationStrategy = new BasicAnnualCostsCalculationStrategy();
                break;

            case TariffConstants.PackagedTariffName:
                annualCostsCalculationStrategy = new PackagedAnnualCostsCalculationStrategy();
                break;

            default:
                throw new Exception("Unexpected name of tariff");
            }

            AnnualCosts = annualCostsCalculationStrategy.GetAnnualCosts(consumption);
        }
Beispiel #2
0
        public void GetAnnualCostsShouldThrowArgumentExceptionWhenConsumptionLessThanZero()
        {
            // Arrange
            var    packagedAnnualCostsCalculationStrategy = new PackagedAnnualCostsCalculationStrategy();
            double consumption = -900;

            // Act
            packagedAnnualCostsCalculationStrategy.GetAnnualCosts(consumption);
        }
Beispiel #3
0
        public void GetAnnualCostsShouldReturn1010()
        {
            // Arrange
            var    packagedAnnualCostsCalculationStrategy = new PackagedAnnualCostsCalculationStrategy();
            double consumption = 4700;

            // Act
            var result = packagedAnnualCostsCalculationStrategy.GetAnnualCosts(consumption);

            // Assert
            Assert.AreEqual(1010.00m, result);
        }