public void WhenCalculateSeriesForUser_ThenReturnsSeries()
        {
            DateTime today = DateTime.UtcNow.Date;

            const int userId = 1;

            var vehicles = new[]
                               {
                                   new Vehicle {VehicleId = 1},
                                   new Vehicle {VehicleId = 2},
                                   new Vehicle {VehicleId = 3}
                               };

            _vehicleRepo
                .Setup(r => r.GetVehicles(userId))
                .Returns(vehicles);

            _fillupRepo
                .Setup(r => r.GetFillups(1))
                .Returns(CreateFillups(today, 1));
            _fillupRepo
                .Setup(r => r.GetFillups(2))
                .Returns(CreateFillups(today, 2));
            _fillupRepo
                .Setup(r => r.GetFillups(3))
                .Returns(CreateFillups(today, 3));

            var target = new ChartDataService(_vehicleRepo.Object, _fillupRepo.Object);
            var actual = target.CalculateSeriesForUser(userId, null, null);

            // 3 vehicles * 7 months
            Assert.Equal(3*7, actual.Entries.Count);

            var actualEntries = new List<StatisticSeriesEntry>(actual.Entries);

            var afeValues = new[] {8.75, 6.67, 5.0, 10.0, 20.0, 6.67, 4};
            var tcValues = new double[] {160, 450, 400, 200, 100, 300, 500};
            var tdValues = new double[] {700, 1000, 1000, 1000, 1000, 1000, 1000};

            for (int i = 0; i < 7; i++)
            {
                Assert.Equal(1, actualEntries[i].Id);
                Assert.Equal(today.AddMonths(-1*(7 - i)).Year, actualEntries[i].Year);
                Assert.Equal(today.AddMonths(-1*(7 - i)).Month, actualEntries[i].Month);
                Assert.Equal(afeValues[i], actualEntries[i].AverageFuelEfficiency);
                Assert.Equal(tcValues[i], actualEntries[i].TotalCost);
                Assert.Equal(tdValues[i], actualEntries[i].TotalDistance);
            }
        }
        public void WhenCalculateSeriesWithNoFillups_ThenReturnsEmptySeries()
        {
            var fillUps = new ReadOnlyCollection<FillupEntry>(new List<FillupEntry>());

            int userId = 1;

            var vehicles = new[]
                               {
                                   new Vehicle {VehicleId = 1, Fillups = fillUps},
                                   new Vehicle {VehicleId = 2, Fillups = fillUps},
                                   new Vehicle {VehicleId = 3, Fillups = fillUps}
                               };

            _vehicleRepo
                .Setup(r => r.GetVehicles(userId))
                .Returns(vehicles);

            var target = new ChartDataService(_vehicleRepo.Object);

            StatisticSeries actual = target.CalculateSeriesForUser(userId, null, null);

            Assert.NotNull(actual);

            // 3 vehicles * 0 months
            Assert.Equal(0, actual.Entries.Count);
        }
        public void WhenConstructed_ThenInitializesValues()
        {
            var actual = new ChartDataService(_vehicleRepo.Object);

            Assert.NotNull(actual);
        }