Beispiel #1
0
        public void GetEntryById_ShouldReturn_DtoDepartureEntity()
        {
            // Arrange
            DepartureEntity departureEntity = new DepartureEntityBuilder()
                                              .WithId(Guid.NewGuid().ToString())
                                              .Build();

            _departureRepository.Setup(r => r.GetById(departureEntity.Id)).Returns(departureEntity);

            var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object);

            // Act
            DtoDeparture result = entryService.GetEntryById(id: departureEntity.Id);

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #2
0
        public void GetEntryByBadId_ShouldReturn_Null()
        {
            // Arrange
            DepartureEntity departureEntity = new DepartureEntityBuilder()
                                              .WithId(Guid.NewGuid().ToString())
                                              .Build();

            var id = Guid.NewGuid().ToString();

            _departureRepository.Setup(r => r.List(dr => dr.IdEntry == id)).Returns(new List <DepartureEntity>());

            var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object);

            // Act
            DepartureEntity result = entryService.GetDepartureByEntryId(id);

            // Assert
            Assert.IsNull(result);
        }
Beispiel #3
0
        public void GetDepartureByVehicleId_ShouldReturn_Null()
        {
            // Arrange
            DepartureEntity departureEntity = new DepartureEntityBuilder()
                                              .WithId(Guid.NewGuid().ToString())
                                              .WithIdVehicle("ASD123")
                                              .Build();

            var vehicleId = "AAA111";

            _departureRepository.Setup(r => r.List(dr => dr.IdVehicle == vehicleId)).Returns(new List <DepartureEntity>());

            var entryService = new DepartureService(_departureRepository.Object, _entryRepository.Object, _rateService.Object, _cellService.Object);

            // Act
            DepartureEntity result = entryService.GetDepartureByVehicleId(vehicleId);

            // Assert
            Assert.IsNull(result);
        }
Beispiel #4
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);
            }
        }