public void CalculateRentalPrice_StartGreaterThanEnd_ShouldThrowException() { var start = new DateTime(2020, 1, 2, 12, 0, 0); var stop = new DateTime(2020, 1, 1, 12, 10, 0); var price = 0.2M; Action asd = () => _calculator.CalculateRentalPrice(start, stop, price); asd.Should().Throw <IncorrectTimeException>(); }
public decimal EndRide(string scooterId) { if (!_activeRides.ContainsKey(scooterId)) { throw new ScooterNotRentedException($"Scooter \"{scooterId}\" is not rented."); } var ride = _activeRides[scooterId]; var endTime = DateTime.Now; var price = _calculator.CalculateRentalPrice(ride.StartTime, endTime, ride.Scooter.PricePerMinute); ride.EndRide(endTime, price); ride.Scooter.IsRented = false; _activeRides.Remove(ride.Scooter.Id); _rideHistory.Add(ride); return(price); }