public void CalculateIncome_GivenYear_FiltersOtherRentals() { var scooters = new List <Scooter> { new Scooter("id1", 1) }; var rentals = new List <Rental> { new Rental { RentalStart = new DateTime(2020, 1, 1) }, new Rental { RentalStart = new DateTime(2020, 1, 1) }, new Rental { RentalStart = new DateTime(2019, 12, 31) } }; _scooterServiceMock.Setup(x => x.GetScooters()).Returns(scooters); _rentalServiceMock.Setup(x => x.GetRentalsByScooterId("id1")).Returns(rentals); _rentalCompany.CalculateIncome(2020, true); _rentalCalculatorMock.Verify(x => x.CalculateScooterRentalPrice(It.IsAny <DateTime>(), It.IsAny <DateTime?>(), 1), Times.Exactly(2)); }
public void CalculateThisYearAllIncomeTest() { var name = "my company"; IScooterService service = new ScooterService(); var date = DateTime.UtcNow; var rentals = new List <RentedScooter> { new RentedScooter { RentalStart = date, RentalEnd = date.AddMinutes(5), ScooterId = "scooter1", PricePerMinute = 0.2m }, new RentedScooter { RentalStart = date, RentalEnd = date.AddDays(5), ScooterId = "scooter2", PricePerMinute = 0.5m }, new RentedScooter { RentalStart = date.AddDays(-2), RentalEnd = null, ScooterId = "scooter3", PricePerMinute = 1.0m } }; IRentalCompany company = new RentalCompany(name, service, new RentalPriceCalculator(renatlCalculatorMaxPrice), rentals); Assert.AreEqual(181.0m, company.CalculateIncome(2020, true)); }
public void CalculateTotalFinishedRentIncomeTest() { var name = "my company"; IScooterService service = new ScooterService(); var date = new DateTime(2019, 12, 30); var rentals = new List <RentedScooter> { new RentedScooter { RentalStart = date, RentalEnd = date.AddMinutes(5), ScooterId = "scooter1", PricePerMinute = 0.2m }, new RentedScooter { RentalStart = date, RentalEnd = date.AddDays(5), ScooterId = "scooter2", PricePerMinute = 0.5m }, new RentedScooter { RentalStart = DateTime.UtcNow.AddDays(-1), RentalEnd = null, ScooterId = "scooter3", PricePerMinute = 1.0m } }; IRentalCompany company = new RentalCompany(name, service, new RentalPriceCalculator(renatlCalculatorMaxPrice), rentals); Assert.AreEqual(101.0m, company.CalculateIncome(null, false)); }