コード例 #1
0
        public void CalculateSavingsPerMonth_ReturnsExpectedValues()
        {
            // arrange
            var calculator = new FuelSavingsCalculator(120, FuelSavingsCalculatorTimeFrame.Week, 20, 29, 1.50m);

            // act
            var savings = calculator.CalculateSavingsPerMonth();

            //assert
            Assert.AreEqual(savings, 12.10);
        }
コード例 #2
0
        private decimal CalculateSavings()
        {
            if (!NecessaryDataIsProvidedToCalculateSavings())
            {
                return(0);
            }

            FuelSavingsCalculatorTimeFrame timeframe;

            Enum.TryParse <FuelSavingsCalculatorTimeFrame>(ddMilesDrivenTimeFrame.SelectedValue, out timeframe);

            var calculator = new FuelSavingsCalculator(
                Convert.ToInt16(txtMilesDriven.Text),
                timeframe,
                Convert.ToInt16(txtTradeMpg.Text),
                Convert.ToInt16(txtNewMpg.Text),
                Convert.ToDecimal(txtPpg.Text));

            return(calculator.CalculateSavingsPerMonth());
        }