Exemplo n.º 1
0
        public decimal CalculateIncome(int?year, bool includeNotCompletedRentals)
        {
            var rentedBikesHistory          = _rentedBikeService.AllRentedBikesHistory(year);
            var completedRentedBikesIncomes = _calculator.AllIncomes(rentedBikesHistory);

            return(completedRentedBikesIncomes + (includeNotCompletedRentals ? _rentedBikeService.AllActiveRentedBikesIncomes(year) : 0));
        }
Exemplo n.º 2
0
        public void AllIncomesTest()
        {
            var firstRentedBike = new RentedBike(new Bike("1", 0.2m), new DateTime(2020, 1, 1));

            firstRentedBike.EndOfRentedBike(new DateTime(2020, 1, 1), 8m);
            var secondRentedBike = new RentedBike(new Bike("1", 0.2m), new DateTime(2020, 1, 1));

            secondRentedBike.EndOfRentedBike(new DateTime(2020, 1, 1), 13m);
            var thirdRentedBike = new RentedBike(new Bike("1", 0.2m), new DateTime(2020, 1, 1));

            thirdRentedBike.EndOfRentedBike(new DateTime(2020, 1, 1), 5m);
            var rentedBikesList = new List <RentedBike> {
                firstRentedBike, secondRentedBike, thirdRentedBike
            };

            var allIncomes = _incomeCalculator.AllIncomes(rentedBikesList);

            Assert.AreEqual(26, allIncomes);
        }