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 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); }