Пример #1
0
        public void WhenVehiclePopulated_ThenTotalDistanceCalculated()
        {
            var fillups = new[]
            {
                new FillupEntry
                {
                    Date     = DateTime.UtcNow.AddMonths(-5),
                    Odometer = 10000,
                    Distance = null
                },
                new FillupEntry
                {
                    Date     = DateTime.UtcNow.AddMonths(-4),
                    Odometer = 12000,
                    Distance = 2000
                },
                new FillupEntry
                {
                    Date     = DateTime.UtcNow.AddMonths(-3),
                    Odometer = 14000,
                    Distance = 2000
                },
                new FillupEntry
                {
                    Date     = DateTime.UtcNow.AddMonths(-3),
                    Odometer = 16000,
                    Distance = 2000
                }
            };

            var target = CalculateStatistics.Calculate(fillups);

            Assert.Equal(16000 - 10000, target.TotalDistance);
        }
Пример #2
0
        public void WhenVehiclePopulated_ThenTotalUnitsCalculated()
        {
            var fillups = new[]
            {
                new FillupEntry()
                {
                    Date = DateTime.UtcNow.AddMonths(-5), TotalUnits = 20.5
                },
                new FillupEntry()
                {
                    Date = DateTime.UtcNow.AddMonths(-4), TotalUnits = 22
                },
                new FillupEntry()
                {
                    Date = DateTime.UtcNow.AddMonths(-3), TotalUnits = 36.253
                },
                new FillupEntry()
                {
                    Date = DateTime.UtcNow.AddMonths(-3), TotalUnits = 21.55
                }
            };

            var target = CalculateStatistics.Calculate(fillups, includeFirst: false);

            Assert.Equal(79.8, Math.Round(target.TotalUnits, 2));
        }
        public void Mode()
        {
            var    calc   = new CalculateStatistics();
            double result = calc.Mean("1,2,3,3");

            Assert.AreEqual("3", result);
        }
Пример #4
0
        public void WhenVehiclePopulated_ThenAverageFillupPriceCalculated()
        {
            var fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date = DateTime.UtcNow.AddMonths(-5), PricePerUnit = 2.95, TotalUnits = 20.5,
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-4),
                PricePerUnit   = 3.16,
                TotalUnits     = 22,
                TransactionFee = 2.90
            });
            fillups.Add(new FillupEntry()
            {
                Date = DateTime.UtcNow.AddMonths(-3), PricePerUnit = 1.90, TotalUnits = 36.253
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-3),
                PricePerUnit   = 3.16,
                TotalUnits     = 21.55,
                TransactionFee = 1.13
            });

            var target = CalculateStatistics.Calculate(fillups, includeFirst: false);

            Assert.Equal(2.59, Math.Round(target.AverageFillupPrice, 2));
        }
        public void Median()
        {
            var    calc   = new CalculateStatistics();
            double result = calc.Mean("1,2,3,4,5,6");

            Assert.AreEqual(3.5, result);
        }
        public void ParseConfig_InvalidConfig_ReturnNull()
        {
            //test if at least one row can be matched
            var strArr  = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ConfigTest1.txt");
            var testObj = new CalculateStatistics(strArr);

            Assert.AreEqual(testObj.ParseConfig(CalculateStatistics.GetCalculationTypes()).Count(), 0);
        }
        public void ParseConfig_ValidConfig_ReturnObject()
        {
            //test if at least one row can be matched
            var strArr   = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ConfigTest2.txt");
            var testObj  = new CalculateStatistics(strArr);
            var dict     = CalculateStatistics.GetCalculationTypes();
            var taskList = testObj.ParseConfig(dict);

            Assert.AreEqual(testObj.ParseConfig(dict).Count, 3);
        }
Пример #8
0
        public ActionResult Statistics()
        {
            ViewBag.Tires  = CalculateStatistics.CountTiresInDb(db.Vehicles.ToList());
            ViewBag.Types  = CalculateStatistics.CountTypesInDb(db.Vehicles.ToList());
            ViewBag.Colors = CalculateStatistics.CountColorOfTypesInDb(db.Vehicles.ToList());
            ViewBag.Makes  = CalculateStatistics.CountMakeInDb(db.Vehicles.ToList());



            return(View());
        }
Пример #9
0
 public void Setup()
 {
     _statistics     = new CalculateStatistics();
     _printCountries = new PrintCountriesInfo();
     countriesTest   = new List <Country>()
     {
         new Country("Chile", "Santiago", 18191900, 756102),
         new Country("Argentina", "Buenos Aires", 2780400, 43590400),
         new Country("Colombia", "Bogotá", 48759958, 1141748),
         new Country("Costa Rica", "San José", 4890379, 51100),
         new Country("Dominican Republic", "Santo Domingo", 10075045, 48671),
         new Country("Ecuador", "Quito", 16545799, 276841)
     };
 }
        public void ProcessData_ResvAssumedMaxMax_ReturnCorrectCalculation()
        {
            var strArr   = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt ResvAssumedMaxMax.txt");
            var testObj  = new CalculateStatistics(strArr);
            var dict     = CalculateStatistics.GetCalculationTypes();
            var taskList = testObj.ParseConfig(dict);

            testObj.ProcessData(taskList);
            string actual = taskList[0].ReturnFinal().Split('\t')[2];
            double calculated = new[] { -27923645.44, -27923645.44, -27923645.44 }.Max();

            Console.WriteLine("acutal is {0}, calculated is {1}", actual, calculated.ToString());
            Assert.AreEqual(actual, calculated.ToString());
        }
        public void ProcessData_CashPremAverageLast_ReturnCorrectCalculation()
        {
            var strArr   = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt CashPremAverageLast.txt");
            var testObj  = new CalculateStatistics(strArr);
            var dict     = CalculateStatistics.GetCalculationTypes();
            var taskList = testObj.ParseConfig(dict);

            testObj.ProcessData(taskList);
            string actual = taskList[0].ReturnFinal().Split('\t')[2];
            double calculated = new[] { 84655947.13, 84655914.86, 84655947.13 }.Average();

            Console.WriteLine("acutal is {0}, calculated is {1}", actual, calculated.ToString());
            Assert.AreEqual(actual, calculated.ToString());
        }
        public void ProcessData_AvePolLoanYieldAverageFirstCashPremAverageLast_ReturnCorrectCalculation()
        {
            var strArr   = InputParser.ValidateInput("/Users/Derek/Projects/StatisticsGenerator/data TotalTemp.txt AvePolLoanYieldAverageFirstCashPremAverageLast.txt");
            var testObj  = new CalculateStatistics(strArr);
            var dict     = CalculateStatistics.GetCalculationTypes();
            var taskList = testObj.ParseConfig(dict);

            testObj.ProcessData(taskList);
            string actual = taskList[0].ReturnFinal().Split('\t')[2];
            double calculated = new[] { 0.00, 0.00, 0.00 }.Average();
            string actual2 = taskList[1].ReturnFinal().Split('\t')[2];
            double calculated2 = new[] { 84655947.13, 84655914.86, 84655947.13 }.Average();

            Assert.AreEqual(actual + actual2, calculated.ToString() + calculated2.ToString());
        }
Пример #13
0
        public void WhenVehiclePopulated_ThenAverageFuelEfficiencyCalculated()
        {
            List <FillupEntry> fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-5),
                Odometer     = 10000,
                Distance     = null,
                PricePerUnit = 2.95,
                TotalUnits   = 20.5,
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-4),
                Odometer       = 10220,
                Distance       = 220,
                PricePerUnit   = 3.16,
                TotalUnits     = 22,
                TransactionFee = 2.90
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-3),
                Odometer     = 11000,
                Distance     = 780,
                PricePerUnit = 1.90,
                TotalUnits   = 36.253
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-3),
                Odometer       = 11131,
                Distance       = 131,
                PricePerUnit   = 3.16,
                TotalUnits     = 21.55,
                TransactionFee = 1.13
            });

            var    target        = CalculateStatistics.Calculate(fillups, includeFirst: false);
            double totalDistance = 11131 - 10000;
            // Ignore the cost of the first fillup, otherwise stats are off
            double totalFuel = 22 + 36.253 + 21.55;

            double efficiency = Math.Round(totalDistance / totalFuel, 2);

            Assert.Equal(efficiency, Math.Round(target.AverageFuelEfficiency, 2));
        }
Пример #14
0
        public void WhenVehiclePopulatedWithIntraMonthData_ThenAverageCostPerMonthCalculatedAtOneMonth()
        {
            List <FillupEntry> fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddDays(-5),
                Odometer     = 10000,
                Distance     = null,
                PricePerUnit = 2.95,
                TotalUnits   = 20.5,
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddDays(-4),
                Odometer       = 10220,
                Distance       = 220,
                PricePerUnit   = 3.16,
                TotalUnits     = 22,
                TransactionFee = 2.90
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddDays(-3),
                Odometer     = 11000,
                Distance     = 780,
                PricePerUnit = 1.90,
                TotalUnits   = 36.253
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddDays(-3),
                Odometer       = 11132,
                Distance       = 132,
                PricePerUnit   = 3.16,
                TotalUnits     = 21.55,
                TransactionFee = 1.13
            });

            var target = CalculateStatistics.Calculate(fillups, includeFirst: false);
            // Ignore the cost of the first fillup, otherwise stats are off
            double totalGasCost = (22 * 3.16 + 36.253 * 1.90 + 21.55 * 3.16);
            double totalCost    = Math.Round(totalGasCost + +2.90 + 1.13, 2);

            Assert.Equal((totalCost) / 1,
                         Math.Round(target.AverageCostPerMonth, 2));
            Assert.Equal(Math.Round(target.TotalCost, 2), Math.Round(target.AverageCostPerMonth, 2));
        }
Пример #15
0
        public void WhenConstructed_ThenIntialized()
        {
            var target = CalculateStatistics.Calculate(new FillupEntry[] {});

            Assert.NotNull(target);
            Assert.Equal(0.0, target.AverageCostPerMonth);
            Assert.Equal(0.0, target.AverageCostToDrive);
            Assert.Equal(0.0, target.AverageFillupPrice);
            Assert.Equal(0.0, target.AverageFuelEfficiency);
            Assert.Null(target.Name);
            Assert.Null(target.Odometer);
            Assert.Equal(0.0, target.TotalCost);
            Assert.Equal(0.0, target.TotalDistance);
            Assert.Equal(0.0, target.TotalFuelCost);
            Assert.Equal(0.0, target.TotalUnits);
        }
        public void WhenAddingFillupGet_ProvidesPrePopulatedModel()
        {
            // this test has some unnessary setup, just to reflect what is happening with data access
            // ultimately, the data access should be improved to remove the extra calls to the db

            var fillups = new List <FillupEntry>
            {
                new FillupEntry
                {
                    VehicleId     = defaultVehicleId,
                    FillupEntryId = defaultFillupId,
                    Odometer      = 500
                },
            };

            // this is where the actual odometer reading originates
            var statistics = CalculateStatistics.Calculate(fillups);

            // fillups is not required on the vehicle for this test to pass
            var vehicles = new List <VehicleModel>
            {
                new VehicleModel(new Vehicle {
                    VehicleId = defaultVehicleId, Fillups = fillups
                }, statistics)
            };

            MockHandlerFor(
                () => new Mock <GetVehicleListForUser>(null),
                x => x
                .Setup(h => h.Execute(defaultUserInfo.UserId))
                .Returns(vehicles));

            // this test will pass even if this handler returns the wrong set of fillups
            MockHandlerFor(
                () => new Mock <GetFillupsForVehicle>(null),
                x => x
                .Setup(h => h.Execute(defaultVehicleId))
                .Returns(fillups));

            var controller = GetTestableFillupController();

            var result = controller.Add(defaultVehicleId);
            var model  = result.Extract <FillupAddViewModel>();

            Assert.NotNull(model);
            Assert.Equal(500, model.FillupEntry.Odometer);
        }
Пример #17
0
        public void WhenVehiclePopulated_ThenAverageCostToDriveCalculated()
        {
            List <FillupEntry> fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-5),
                Odometer     = 10000,
                Distance     = null,
                PricePerUnit = 2.95,
                TotalUnits   = 20.5,
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-4),
                Odometer       = 10220,
                Distance       = 220,
                PricePerUnit   = 3.16,
                TotalUnits     = 22,
                TransactionFee = 2.90
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-3),
                Odometer     = 11000,
                Distance     = 780,
                PricePerUnit = 1.90,
                TotalUnits   = 36.253
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-3),
                Odometer       = 11132,
                Distance       = 132,
                PricePerUnit   = 3.16,
                TotalUnits     = 21.55,
                TransactionFee = 1.13
            });

            var    target        = CalculateStatistics.Calculate(fillups, includeFirst: false);
            double totalDistance = 11132 - 10000;
            // Ignore the cost of the first fillup, otherwise stats are off
            double totalCost       = 22 * 3.16 + 36.253 * 1.90 + 21.55 * 3.16 + 2.9 + 1.13;
            double costPerDistance = Math.Round(totalCost / totalDistance, 2);

            Assert.Equal(costPerDistance, Math.Round(target.AverageCostToDrive, 2));
        }
Пример #18
0
        public void WhenEfficiencyGreaterThanHundred_ThenMagnitudeFormatsCorrectly()
        {
            var fillups = new[]
            {
                new FillupEntry {
                    Distance = 0, TotalUnits = 0
                },
                new FillupEntry {
                    Distance = 8888, TotalUnits = 10
                },
            };
            var vehicle = new VehicleModel(new Vehicle(), CalculateStatistics.Calculate(fillups));

            var actual   = _helper.AverageFuelEfficiencyMagnitude(vehicle);
            var expected = MvcHtmlString.Create("hundreds");

            Assert.Equal(expected.ToHtmlString(), actual.ToHtmlString());
        }
Пример #19
0
        public void WhenEfficiencyGreaterThan99Thousand_ThenNumberFormatsCorrectly()
        {
            var fillups = new[]
            {
                new FillupEntry {
                    Distance = 0, TotalUnits = 0
                },
                new FillupEntry {
                    Distance = 150000, TotalUnits = 10
                },
            };
            var vehicle = new VehicleModel(new Vehicle(), CalculateStatistics.Calculate(fillups));

            var actual   = _helper.AverageFuelEfficiencyText(vehicle);
            var expected = MvcHtmlString.Create("15.0k");

            Assert.Equal(expected.ToHtmlString(), actual.ToHtmlString());
        }
Пример #20
0
        private void CalculateSeriesForVehicle(Vehicle vehicle, StatisticSeries series, DateTime?startDate, DateTime?endDate)
        {
            Debug.Assert(series != null);

            DateTime startFilterDate = startDate ?? DateTime.MinValue;
            DateTime endFilterDate   = endDate ?? DateTime.UtcNow;

            var fillUps = _fillupRepository.GetFillups(vehicle.VehicleId);

            var fillupGroups = from fillUp in fillUps
                               where ((fillUp.Date >= startFilterDate) && (fillUp.Date <= endFilterDate))
                               group fillUp by new { Year = fillUp.Date.Year, Month = fillUp.Date.Month }
            into g
            orderby g.Key.Year, g.Key.Month
            select g;

            var firstFillUp = fillUps.OrderBy(x => x.Date).FirstOrDefault();

            VehicleStatisticsModel statistics;

            foreach (var fillupGroup in fillupGroups)
            {
                var includeFirstFillup = (fillupGroup.Key.Year != firstFillUp.Date.Year) ||
                                         (fillupGroup.Key.Month != firstFillUp.Date.Month);

                statistics = CalculateStatistics.Calculate(fillupGroup, includeFirstFillup);

                Debug.Assert(firstFillUp != null);


                var seriesEntry = new StatisticSeriesEntry
                {
                    Id    = vehicle.VehicleId,
                    Name  = vehicle.Name,
                    Year  = fillupGroup.Key.Year,
                    Month = fillupGroup.Key.Month,
                    AverageFuelEfficiency = Math.Round(statistics.AverageFuelEfficiency, 2),
                    TotalCost             = Math.Round(statistics.TotalCost, 2),
                    TotalDistance         = statistics.TotalDistance,
                };
                series.Entries.Add(seriesEntry);
            }
        }
Пример #21
0
        public void WhenVehiclePopulated_ThenTotalCostCalculated()
        {
            List <FillupEntry> fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-5),
                PricePerUnit = 2.95,
                TotalUnits   = 20.5,
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-4),
                PricePerUnit   = 3.16,
                TotalUnits     = 22,
                TransactionFee = 2.90
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-3),
                PricePerUnit = 1.90,
                TotalUnits   = 36.253
            });
            fillups.Add(new FillupEntry()
            {
                Date           = DateTime.UtcNow.AddMonths(-3),
                PricePerUnit   = 3.16,
                TotalUnits     = 21.55,
                TransactionFee = 1.13
            });

            var target = CalculateStatistics.Calculate(fillups, includeFirst: false);
            // Ignore the cost of the first fillup, otherwise stats are off
            double totalCost = (22 * 3.16 + 36.253 * 1.90 + 21.55 * 3.16 + 2.9 + 1.13);

            Assert.Equal(Math.Round(totalCost, 2), Math.Round(target.TotalCost, 2));
        }
Пример #22
0
 private void InitializeFixture()
 {
     this.target = new FleetStatistics(new[]
     {
         CalculateStatistics.Calculate(new[]
         {
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-5),
                 Odometer       = 1000,
                 Distance       = null,
                 PricePerUnit   = 1,
                 TotalUnits     = 10,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-4),
                 Odometer       = 2000,
                 Distance       = 1000,
                 PricePerUnit   = 1,
                 TotalUnits     = 10,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-3),
                 Odometer       = 3000,
                 Distance       = 1000,
                 PricePerUnit   = 1,
                 TotalUnits     = 10,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-2),
                 Odometer       = 4000,
                 Distance       = 1000,
                 PricePerUnit   = 1,
                 TotalUnits     = 10,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-1),
                 Odometer       = 5000,
                 Distance       = 1000,
                 PricePerUnit   = 1,
                 TotalUnits     = 10,
                 TransactionFee = 1.5
             },
         }, includeFirst: false),
         CalculateStatistics.Calculate(new[]
         {
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-6),
                 Odometer       = 1000,
                 Distance       = null,
                 PricePerUnit   = 3,
                 TotalUnits     = 20,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-5),
                 Odometer       = 2000,
                 Distance       = 1000,
                 PricePerUnit   = 3,
                 TotalUnits     = 20,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-3),
                 Odometer       = 3000,
                 Distance       = 1000,
                 PricePerUnit   = 3,
                 TotalUnits     = 20,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-3),
                 Odometer       = 4000,
                 Distance       = 1000,
                 PricePerUnit   = 3,
                 TotalUnits     = 20,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow,
                 Odometer       = 5000,
                 Distance       = 1000,
                 PricePerUnit   = 3,
                 TotalUnits     = 20,
                 TransactionFee = 1.5
             },
         }, includeFirst: false),
         CalculateStatistics.Calculate(new[]
         {
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-12),
                 Odometer       = 3000,
                 Distance       = null,
                 PricePerUnit   = 2,
                 TotalUnits     = 30,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-10),
                 Odometer       = 4000,
                 Distance       = 1000,
                 PricePerUnit   = 2,
                 TotalUnits     = 30,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-8),
                 Odometer       = 5000,
                 Distance       = 1000,
                 PricePerUnit   = 2,
                 TotalUnits     = 30,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-6),
                 Odometer       = 6000,
                 Distance       = 1000,
                 PricePerUnit   = 2,
                 TotalUnits     = 30,
                 TransactionFee = 1.5
             },
             new FillupEntry
             {
                 Date =
                     DateTime.UtcNow.
                     AddMonths(-4),
                 Odometer       = 7000,
                 Distance       = 1000,
                 PricePerUnit   = 2,
                 TotalUnits     = 30,
                 TransactionFee = 1.5
             },
         }, includeFirst: false)
     });
 }
        public void Test1()
        {
            var calc = new CalculateStatistics();

            Assert.AreEqual(2, calc.Mean("1,2,3"));
        }
Пример #24
0
        public void WhenIncludeFirstFillupTrue_ThenFirstFillupIncluded()
        {
            List <FillupEntry> fillups = new List <FillupEntry>();

            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-5),
                Odometer     = 10000,
                Distance     = null,
                PricePerUnit = 1,
                TotalUnits   = 10,
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-4),
                Odometer     = 11000,
                Distance     = 1000,
                PricePerUnit = 1,
                TotalUnits   = 10,
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-3),
                Odometer     = 12000,
                Distance     = 1000,
                PricePerUnit = 1,
                TotalUnits   = 10,
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-2),
                Odometer     = 13000,
                Distance     = 1000,
                PricePerUnit = 1,
                TotalUnits   = 10,
            });
            fillups.Add(new FillupEntry()
            {
                Date         = DateTime.UtcNow.AddMonths(-1),
                Odometer     = 14000,
                Distance     = 1000,
                PricePerUnit = 1,
                TotalUnits   = 10,
            });

            var target = CalculateStatistics.Calculate(fillups, includeFirst: true);

            double totalDistance = 14000 - 10000;
            // Ignore the cost of the first fillup, otherwise stats are off
            double totalCost       = 10 * 5;
            double fuelCost        = 10 * 5;
            double totalFuel       = 10 * 5;
            double avgCostPerMonth = Math.Round(totalCost / 5, 2);
            double avgCostToDrive  = Math.Round(totalCost / totalDistance, 2);
            double avgEfficiency   = Math.Round(totalDistance / totalFuel, 2);

            Assert.Equal(avgCostPerMonth, Math.Round(target.AverageCostPerMonth, 2));
            Assert.Equal(avgCostToDrive, Math.Round(target.AverageCostToDrive, 2));
            Assert.Equal(1, Math.Round(target.AverageFillupPrice, 2));
            Assert.Equal(avgEfficiency, Math.Round(target.AverageFuelEfficiency, 2));
            Assert.Equal(14000, target.Odometer);
            Assert.Equal(totalCost, Math.Round(target.TotalCost, 2));
            Assert.Equal(totalDistance, target.TotalDistance);
            Assert.Equal(fuelCost, Math.Round(target.TotalFuelCost, 2));
            Assert.Equal(totalFuel, Math.Round(target.TotalUnits, 2));
        }