public void RegisterVehicle_WithoutCellAvaliable_ShouldReturnException() { // Arrange (preparación, organizar) var entryBuilder = new EntryDTOBuilder() .WithVehicleId("SFL555") .WithVehicleType(VehicleTypeEnum.car); _cellService.Setup(cs => cs.ExistsQuotaByVehicleType(VehicleTypeEnum.car)).Returns(false); var entryService = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); DtoEntry entry = entryBuilder.Build(); // Act try { entryService.RegistryVehicle(entry); } catch (Exception e) { var message = "No hay cupos disponibles"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(CellException)); Assert.AreEqual(e.Message, message); } }
public void RegisterMotorcycle_WithoutCC_ShouldReturnException() { // Arrange (preparación, organizar) var entryBuilder = new EntryDTOBuilder(); DtoEntry entry = entryBuilder .WithCC(null) .Build(); // cuando se ejecute este método en el entry service va a retornar true en la validacion de ExistsQuotaByVehicleType _cellService.Setup(cs => cs.ExistsQuotaByVehicleType(VehicleTypeEnum.motorcycle)).Returns(true); _placaService.Setup(ps => ps.GetLastNumberOfIdVehicle(entry.IdVehicleType, entry.IdVehicle)).Returns("5"); var entryService = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act try { entryService.RegistryVehicle(entry); } catch (Exception e) { var message = "Falta la información del cilindraje de la motocicleta"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(EntryException)); Assert.AreEqual(e.Message, message); } }
public void RegisterCar_WithBadIdVehicleFormat_ShouldReturnException() { // Arrange (preparación, organizar) var entryBuilder = new EntryDTOBuilder() .WithVehicleId("SFL55A") .WithVehicleType(VehicleTypeEnum.car); DtoEntry entry = entryBuilder.Build(); _cellService.Setup(cs => cs.ExistsQuotaByVehicleType(VehicleTypeEnum.car)).Returns(true); var entryService = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act try { entryService.RegistryVehicle(entry); } catch (Exception e) { var message = "Hubo un problema al leer la placa del vehículo. Verifique el tipo de vehículo e intente de nuevo"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(EntryException)); Assert.AreEqual(e.Message, message); } }
public void EntryVehicle_ShouldReturn_CellWithAvaliableWith1Decrease() { // Arrange DtoEntry entryDTOBuilder = new EntryDTOBuilder() .WithVehicleType(VehicleTypeEnum.car) .WithVehicleId("AAA117") .Build(); var cellsAvaliableBeforeEntry = cellRepository.List(cr => cr.IdVehicleType == VehicleTypeEnum.car).FirstOrDefault()?.NumCellAvaliable; // Act entryService.RegistryVehicle(entryDTOBuilder); var cellByVehicleType = cellRepository.List(cr => cr.IdVehicleType == VehicleTypeEnum.car).FirstOrDefault(); // Assert Assert.IsTrue(cellByVehicleType.NumCellAvaliable == (cellsAvaliableBeforeEntry - 1)); }
public void EntryVehicle_WithoutCellAvaliable_ShouldReturnAnException() { // Arrange DtoEntry entryDTOBuilder = new EntryDTOBuilder().WithVehicleType(AppCore.Enums.VehicleTypeEnum.car).WithVehicleId("AAA111").Build(); var response = "No hay cupos disponibles"; cellService.DecreaseCell(VehicleTypeEnum.car, 20); // Act try { entryService.RegistryVehicle(entryDTOBuilder); } catch (Exception e) { // Assert Assert.AreEqual(e.Message, response); throw; } }
public void RegisterVehicle_WithPendingDeparture_ShouldReturnException() { // Arrange (preparación, organizar) var entryBuilder = new EntryDTOBuilder() .WithVehicleId("SFL55D") .WithVehicleType(VehicleTypeEnum.motorcycle) .WithCC("1000"); var uniqueId = Guid.NewGuid().ToString(); var entryList = new List <EntryEntity>(); var entryEntity = new EntryEntityBuilder().Build(); entryList.Add(entryEntity); var departureEntity = new DepartureEntityBuilder() .WithIdEntry(uniqueId) .Build(); DtoEntry entry = entryBuilder.Build(); entryRepository.Setup(er => er.List(e => e.IdVehicle == entry.IdVehicle)).Returns(entryList); var entryService = new EntryService(entryRepository.Object, _cellService.Object, _departureService.Object, _placaService.Object); // Act try { entryService.RegistryVehicle(entry); } catch (Exception e) { var message = "El vehículo que está registrando posee una salida pendiente"; // Assert (confirmacion) Assert.IsInstanceOfType(e, typeof(EntryException)); Assert.AreEqual(e.Message, message); } }