Exemplo n.º 1
0
        public decimal CalculateIncome(int?year, bool includeNotCompletedRentals)
        {
            var rideHistory = _rideService.GetRideHistory(year);

            var completedRidesIncome = _calculator.CalculateIncome(rideHistory);

            return(completedRidesIncome + (includeNotCompletedRentals ? _rideService.GetActiveRidesPrice(year) : 0));
        }
        public void CalculateIncome()
        {
            var ride1 = new Ride(new Scooter("1", 0.2M), new DateTime(2019, 1, 1));

            ride1.EndRide(new DateTime(2019, 1, 1), 14M);
            var ride2 = new Ride(new Scooter("2", 0.2M), new DateTime(2019, 1, 1));

            ride2.EndRide(new DateTime(2019, 1, 1), 15M);
            var ride3 = new Ride(new Scooter("3", 0.2M), new DateTime(2019, 1, 1));

            ride3.EndRide(new DateTime(2019, 1, 1), 16M);
            var list = new List <Ride> {
                ride1, ride2, ride3
            };

            _calculator.CalculateIncome(list).Should().Be(45);
        }