public void AddScooterNotExistsData(string scooterId, decimal pricePerMinute) { _scooterService.AddScooter(scooterId, pricePerMinute); Scooter scooter = _scooterService.GetScooterById(scooterId); Assert.Equal(scooter.Id, scooterId); Assert.Equal(scooter.PricePerMinute, pricePerMinute); }
public void GetScooterById_CorrectId_ShouldReturnScooter() { service.AddScooter("1", 0.2M); var scooter = service.GetScooterById("1"); scooter.Id.Should().Be("1"); }
private Scooter GetScooter(string id) { if (_scooterService.GetScooterById(id) == null) { throw new ScooterNotFoundException(); } return(_scooterService.GetScooterById(id)); }
public void AddScooter() { var newScooterId = "1"; Assert.IsNull(ScooterService.GetScooterById(newScooterId)); ScooterService.AddScooter(newScooterId, 1); Assert.IsNotNull(ScooterService.GetScooterById(newScooterId)); }
public void RentScooter() { var newScooterId = "1"; ScooterService.AddScooter(newScooterId, 1); Assert.DoesNotThrow(() => RentalCompany.StartRent(newScooterId)); Assert.IsTrue(ScooterService.GetScooterById(newScooterId).IsRented); }
public void RemoveScooter_RentedScooter_ThrowsExceptionScooterIsRented() { // Arrange string scooterId = "Scooter"; // Act _scooterService.ScooterList.Add(new Scooter(scooterId, 0.5m)); _scooterService.GetScooterById(scooterId).IsRented = true; // Assert Assert.ThrowsException <ScooterIsRented>(() => _scooterService.RemoveScooter(scooterId)); }
/// <inheritdoc /> public decimal EndRent(string id) { var rental = _rentalService.EndRentalByScooterId(id); var scooter = _scooterService.GetScooterById(id); return(_rentalCalculator.CalculateScooterRentalPrice(rental.RentalStart, rental.RentalEnd, scooter.PricePerMinute)); }
public void GetScooterById_WithValidId_ReturnsScooter() { var scooter = new Scooter("id", 1); _scooterRepositoryMock.Setup(x => x.GetById("id")).Returns(scooter); var result = _scooterService.GetScooterById("id"); _scooterRepositoryMock.Verify(x => x.GetById("id")); result.Should().Be(scooter); }
public decimal EndRent(string scooterId) { var scooter = ScooterService.GetScooterById(scooterId); if (scooter == null) { throw new ScooterDoesNotExistExeption(); } var activeRent = rentRepository.GetAll().FirstOrDefault(r => r.Scooter.Id == scooterId && !r.EndTimestamp.HasValue); if (activeRent == null) { throw new NoActiveRentException(); } activeRent.EndTimestamp = TimeProvider.TimeProvider.Current.Now; scooter.IsRented = false; return(CalculateRentalPrice(activeRent.StartTimestamp, activeRent.EndTimestamp.Value, scooter.PricePerMinute)); }
public string Get(int id) { return(_scooterService.GetScooterById(id).ToString()); }
public void StartRent(string id) { var scooterToRent = _scooterService.GetScooterById(id); _rideService.StartRide(scooterToRent); }