public void RegisterDeparture_WithBadCCEntry_ShouldReturnAnException() { // Arrange (preparación) var response = "No fue posible determinar el cilindraje del vehículo"; var IdVehicleType = VehicleTypeEnum.motorcycle; var idVehicle = "AAABBB"; DtoDeparture departure = new DepartureDTOBuilder() .WithIdVehicle(idVehicle) .Build(); var EntryEntity = new List <EntryEntity>(); EntryEntity.Add(new EntryEntity() { IdVehicle = departure.IdVehicle, IdVehicleType = IdVehicleType }); _entryRepository.Setup(repo => repo.List(er => er.IdVehicle == idVehicle)).Returns(EntryEntity); _rateService.Setup(rs => rs.GetRateByVehicleType(IdVehicleType)).Returns(new RateEntity()); var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object); // Act try { var result = entryService.RegistryDeparture(departure); } catch (Exception e) { // Assert Assert.AreEqual(e.Message, response); throw; } }
public void RegisterDeparture_WithoutRateConfiguration_ShouldReturnAnException() { // Arrange (preparación) var response = "No existe una tarifa configurada para el tipo de vehículo"; var idVehicle = "AAA111"; DtoDeparture departureDTOBuilder = new DepartureDTOBuilder() .WithIdVehicle(idVehicle) .Build(); var EntryEntity = new List <EntryEntity>(); EntryEntity.Add(new EntryEntity() { IdVehicle = departureDTOBuilder.IdVehicle }); _entryRepository.Setup(repo => repo.List(er => er.IdVehicle == idVehicle)).Returns(EntryEntity); var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object); // Act try { var result = entryService.RegistryDeparture(departureDTOBuilder); } catch (Exception e) { // Assert Assert.AreEqual(e.Message, response); throw; } }
public void RegisterDeparture_WithoutEntry_ShouldReturnAnException() { // Arrange (preparación) DtoDeparture departureDTOBuilder = new DepartureDTOBuilder() .WithIdVehicle("AAA111") .Build(); var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object); // Act entryService.RegistryDeparture(departureDTOBuilder); }
public void DepartureOfCar_With1DayAnd3Hours_ShouldReturnAValueToPayOf11000() { // Arrange var idVehicle = "SFL555"; DtoDeparture entryDTOBuilder = new DepartureDTOBuilder().WithIdVehicle(idVehicle).Build(); var valueToPay = 11000; entryRepository.Add(new EntryEntity() { EntryTime = DateTime.Now.Subtract(TimeSpan.FromHours(27).Subtract(TimeSpan.FromSeconds(5))), IdVehicle = idVehicle, IdVehicleType = AppCore.Enums.VehicleTypeEnum.car, Id = Guid.NewGuid().ToString() }); // Act cellService.DecreaseCell(AppCore.Enums.VehicleTypeEnum.car, 1); var response = departureService.RegistryDeparture(entryDTOBuilder); // Assert Assert.AreEqual(response.RateValue, valueToPay); }