コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }