Ejemplo n.º 1
0
        public void FuelConsumptionCalculations()
        {
            // Setup
            FuelCalculator fuelCalculator = new FuelCalculator();

            fuelCalculator.SetCurrentReading(900);
            fuelCalculator.SetPreviousReading(100);
            fuelCalculator.SetFuelAmount(40);
            fuelCalculator.SetUnitPrice(12.84);

            // Exercise and validate
            Assert.AreEqual(20, fuelCalculator.CalcConsumptionKilometerPerLiter(), 0.01);
            Assert.AreEqual(0.05, fuelCalculator.CalcFuelConsumptionPerKm(), 0.01);
            Assert.AreEqual(0.08, fuelCalculator.CalcConsumptionPerUsMile(), 0.01);
            Assert.AreEqual(0.5, fuelCalculator.CalcFuelConsumptionPerSweMil(), 0.01);
            Assert.AreEqual(0.64, fuelCalculator.CalcCostPerKm(), 0.01);

            // Tear down by garbage collection.
        }