public void GetLastNumber_WithBadLength_ShouldReturnException() { // Arrange (preparación, organizar) var PlacaService = new PlacaService(_placaRepository.Object, _picoPlacarepository.Object); VehicleTypeEnum vehicleType = VehicleTypeEnum.motorcycle; string vehicleId = "SFL55"; var placaEntity = new PlacaBuilder() .WithLastNumberFrom(2) .Build(); var listRepository = new List <PlacaEntity>(); listRepository.Add(placaEntity); _placaRepository.Setup(pr => pr.List(r => r.Type == VehicleTypeEnum.motorcycle)).Returns(listRepository); // Act try { PlacaService.GetLastNumberOfIdVehicle(vehicleType, vehicleId); } catch (Exception e) { var message = "La placa del vehículo posee un problema en el formato. La longitud debe ser de 6"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(PlacaException)); Assert.AreEqual(e.Message, message); } }
public void Setup() { var optionsBuilder = new DbContextOptionsBuilder <ParkingDbContext>().UseInMemoryDatabase("integrationTestDB"); contexto = new ParkingDbContext(optionsBuilder.Options); _placaRepository = new Repository <PlacaEntity>(contexto); _picoPlacarepository = new Repository <PicoPlacaDigits>(contexto); placaService = new PlacaService(_placaRepository, _picoPlacarepository); contexto.Database.EnsureCreated(); }
public void Setup() { var optionsBuilder = new DbContextOptionsBuilder <ParkingDbContext>().UseInMemoryDatabase("integrationTestDB"); contexto = new ParkingDbContext(optionsBuilder.Options); entryRepository = new Repository <EntryEntity>(contexto); cellRepository = new Repository <CellEntity>(contexto); departureRepository = new Repository <DepartureEntity>(contexto); rateRepository = new Repository <RateEntity>(contexto); placaRepository = new Repository <PlacaEntity>(contexto); picoPlacarepository = new Repository <PicoPlacaDigits>(contexto); cellService = new CellService(cellRepository); rateService = new RateService(rateRepository); placaService = new PlacaService(placaRepository, picoPlacarepository); departureService = new DepartureService(departureRepository, entryRepository, rateService, cellService); contexto.Database.EnsureCreated(); }
public void HasPicoPlaca_ShouldReturnFalse_WhenExistsPicoPlaca() { // Arrange var vehicleTypeId = VehicleTypeEnum.car; var placaEntity = new PlacaBuilder().Build(); var result = placaEntity; int day = 5; int vehicleLastNumberId = 9; var listPicoPlaca = new List <PicoPlacaDigits>(); _placaRepository.Setup(setup => setup.List(repo => repo.Type == vehicleTypeId)).Returns(new List <PlacaEntity> { placaEntity }); _picoPlacarepository.Setup(setup => setup.List(repo => repo.PlacaEntityID == result.Id && repo.Day == day && repo.Digit == vehicleLastNumberId)).Returns(listPicoPlaca); var placaService = new PlacaService(_placaRepository.Object, _picoPlacarepository.Object); var response = placaService.HasPicoPlaca(vehicleTypeId, day, vehicleLastNumberId); Assert.IsFalse(response); }