public SetExitCustomsOfficeForNotificationByIdHandlerTests()
        {
            this.context = new TestIwsContext();
            var repository = A.Fake<ITransportRouteRepository>();

            anyNotification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 0);
            EntityHelper.SetEntityId(anyNotification, notificationId);

            transport = new TransportRoute(notificationId);

            context.NotificationApplications.Add(anyNotification);
            context.TransportRoutes.Add(transport);

            country = CountryFactory.Create(AnyGuid);
            nonEuCountry = CountryFactory.Create(new Guid("606ECF5A-6571-4803-9CCA-7E1AF82D147A"), "test", false);

            context.Countries.AddRange(new[]
            {
                country,
                nonEuCountry
            });

            stateOfExport = new StateOfExport(country,
                CompetentAuthorityFactory.Create(AnyGuid, country),
                EntryOrExitPointFactory.Create(AnyGuid, country));

            stateOfImportNonEu = new StateOfImport(nonEuCountry,
                CompetentAuthorityFactory.Create(new Guid("5E4F1F22-5054-449B-9EC7-933A43BB5D6D"), nonEuCountry),
                EntryOrExitPointFactory.Create(new Guid("9781324F-17B8-4009-89B2-C18963E3E6E1"), nonEuCountry));

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport);

            this.handler = new SetExitCustomsOfficeForNotificationByIdHandler(context, repository);
        }
Esempio n. 2
0
        public async Task <Guid> HandleAsync(SetStateOfImportForNotification message)
        {
            var transportRoute = await repository.GetByNotificationId(message.NotificationId);

            if (transportRoute == null)
            {
                transportRoute = new TransportRoute(message.NotificationId);
                context.TransportRoutes.Add(transportRoute);
            }

            var country = await context.Countries.SingleAsync(c => c.Id == message.CountryId);

            var competentAuthority =
                await context.CompetentAuthorities.SingleAsync(ca => ca.Id == message.CompetentAuthorityId);

            var entryPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.EntryOrExitPointId);

            var stateOfImport = new StateOfImport(country, competentAuthority, entryPoint);

            var acceptableImportStates = await iceaRepository.GetAllAsync();

            var validator = new TransportRouteValidation(await iceaRepository.GetAllAsync(),
                                                         await this.context.UnitedKingdomCompetentAuthorities.ToArrayAsync());

            transportRoute.SetStateOfImportForNotification(stateOfImport, validator);

            await context.SaveChangesAsync();

            return(stateOfImport.Id);
        }
Esempio n. 3
0
        public void SetStateOfImport_SameCountryToStateOfExportIfNoSameCountryExportsAllowed_Throws()
        {
            // Arrange
            var exportCountry = countries[0];

            var exportCompetentAuthority = CompetentAuthorityFactory.Create(guids[0], exportCountry);
            var exportExitPoint          = EntryOrExitPointFactory.Create(guids[0], exportCountry);

            var importCompetentAuthority = CompetentAuthorityFactory.Create(guids[1], exportCountry);
            var importExitPoint          = EntryOrExitPointFactory.Create(guids[1], exportCountry);

            var stateOfExport = new StateOfExport(exportCountry,
                                                  exportCompetentAuthority,
                                                  exportExitPoint);

            var stateOfImport = new StateOfImport(exportCountry,
                                                  importCompetentAuthority,
                                                  importExitPoint);

            A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true);
            A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(stateOfImport, stateOfExport)).Returns(false);

            // Act
            var intraCountryExportAlloweds = new TestableIntraCountryExportAllowed[0];

            transportRoute.SetStateOfExportForNotification(stateOfExport, this.validator);

            // Assert
            Assert.Throws <InvalidOperationException>(() => transportRoute.SetStateOfImportForNotification(stateOfImport, this.validator));
        }
Esempio n. 4
0
 public TransportRouteData(IList <TransitState> transitStates,
                           StateOfExport stateOfExport,
                           StateOfImport stateOfImport,
                           bool hasNoTransitStates)
 {
     TransitStates      = transitStates;
     StateOfExport      = stateOfExport;
     StateOfImport      = stateOfImport;
     HasNoTransitStates = hasNoTransitStates;
 }
 public TransportRouteData(IList<TransitState> transitStates, 
     StateOfExport stateOfExport, 
     StateOfImport stateOfImport,
     bool hasNoTransitStates)
 {
     TransitStates = transitStates;
     StateOfExport = stateOfExport;
     StateOfImport = stateOfImport;
     HasNoTransitStates = hasNoTransitStates;
 }
Esempio n. 6
0
        public void CustomsOfficesRequired_TransitStatesInEU_None()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.EntryAndExit, result);
        }
Esempio n. 7
0
        public void CustomsOfficesRequired_StateOfImportOutsideEU_Exit()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                                                  europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.EntryAndExit, result);
        }
        public void SetExitCustomsOffice_NotRequired_Throws()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);

            var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2,
                europeanEntryOrExitPoints2[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            Assert.Throws<InvalidOperationException>(
                () =>
                    transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("test", "test", europeanCountry1)));
        }
        public void SetStateOfImport_NotificationAlreadyHasStateOfImport_ReplacesStateOfImport()
        {
            var competentAuthority = GetTestCompetentAuthority(countries[0]);
            var entryPoint = GetTestEntryOrExitPoint(countries[0]);

            var stateOfImport = new StateOfImport(countries[0],
                competentAuthority,
                entryPoint);

            transportRoute.SetStateOfImportForNotification(stateOfImport);

            transportRoute.SetStateOfImportForNotification(stateOfImport);

            Assert.Equal(stateOfImport.CompetentAuthority.Id, transportRoute.StateOfImport.CompetentAuthority.Id);
        }
Esempio n. 10
0
        public void SetStateOfImportForNotification(StateOfImport stateOfImport)
        {
            Guard.ArgumentNotNull(() => stateOfImport, stateOfImport);

            if (StateOfExport != null && StateOfExport.Country.Id == stateOfImport.Country.Id)
            {
                throw new InvalidOperationException(
                    string.Format(
                        "Cannot add a State of Import in the same country as the State of Export for TransportRoute {0}. Country: {1}",
                        Id,
                        StateOfExport.Country.Name));
            }

            StateOfImport = stateOfImport;
        }
Esempio n. 11
0
        public async Task <ActionResult> Index(Guid id, StateOfImportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var stateOfImport = new StateOfImport(id)
            {
                CompetentAuthorityId = model.CompetentAuthorityId,
                EntryPointId         = model.EntryPointId
            };

            await mediator.SendAsync(new SetDraftData <StateOfImport>(id, stateOfImport));

            return(RedirectToAction("Index", "TransitState"));
        }
Esempio n. 12
0
        public void SetExitCustomsOffice_Required_Sets()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                                                  europeanEntryOrExitPoints1[0]);

            var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1,
                                                  nonEuEntryOrExitPoints1[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("test", "test", europeanCountry1));

            Assert.Equal("test", transportRoute.ExitCustomsOffice.Name);
            Assert.Equal("test", transportRoute.ExitCustomsOffice.Address);
            Assert.Equal(europeanCountry1.Id, transportRoute.ExitCustomsOffice.Country.Id);
        }
        public void SetExitCustomsOffice_Required_Sets()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);

            var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1,
                nonEuEntryOrExitPoints1[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("test", "test", europeanCountry1));

            Assert.Equal("test", transportRoute.ExitCustomsOffice.Name);
            Assert.Equal("test", transportRoute.ExitCustomsOffice.Address);
            Assert.Equal(europeanCountry1.Id, transportRoute.ExitCustomsOffice.Country.Id);
        }
Esempio n. 14
0
        public void SetStateOfImport_NotificationAlreadyHasStateOfImport_ReplacesStateOfImport()
        {
            var competentAuthority = GetTestCompetentAuthority(countries[0]);
            var entryPoint         = GetTestEntryOrExitPoint(countries[0]);

            var stateOfImport = new StateOfImport(countries[0],
                                                  competentAuthority,
                                                  entryPoint);

            var intraCountryExportAlloweds = new TestableIntraCountryExportAllowed[0];

            A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(stateOfImport, null)).Returns(true);

            transportRoute.SetStateOfImportForNotification(stateOfImport, this.validator);

            transportRoute.SetStateOfImportForNotification(stateOfImport, this.validator);

            Assert.Equal(stateOfImport.CompetentAuthority.Id, transportRoute.StateOfImport.CompetentAuthority.Id);
        }
Esempio n. 15
0
        public void CustomsOfficesRequired_StateOfTransitInsideEUImportOutside_Exit()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                                                  europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(nonEuCountry2, nonEuCompetentAuthority2,
                                                  nonEuEntryOrExitPoints2[0]);

            var transitState = new TransitState(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0],
                                                europeanEntryOrExitPoints2[1], 1);

            transportRoute.AddTransitStateToNotification(transitState);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.EntryAndExit, result);
        }
Esempio n. 16
0
        private StateOfImport GenerateStateOfImport(Draft.StateOfImport stateOfImport,
                                                    TransportRouteLookups lookups)
        {
            var returnValue = new StateOfImport();

            if (stateOfImport.CompetentAuthorityId.HasValue)
            {
                var competentAuthority = lookups.GetCompetentAuthority(stateOfImport.CompetentAuthorityId);

                returnValue.CompetentAuthorityCode = competentAuthority.Code;
                returnValue.CompetentAuthorityName = competentAuthority.Name;
            }

            if (stateOfImport.EntryPointId.HasValue)
            {
                returnValue.EntryPointName = lookups.GetEntryOrExitPoint(stateOfImport.EntryPointId).Name;
            }

            return(returnValue);
        }
        public static TransportRoute CreateCompleted(Guid id, Guid notificationId,
            IList<EntryOrExitPoint> entryOrExitPoints, IList<CompetentAuthority> competentAuthorities)
        {
            var transportRoute = new TransportRoute(notificationId);
            EntityHelper.SetEntityId(transportRoute, id);

            var exitPoint =
                entryOrExitPoints.OrderBy(ep => ep.Country.Name).First(ep => ep.Country.IsEuropeanUnionMember);
            var stateOfExport = new StateOfExport(exitPoint.Country,
                competentAuthorities.First(ca => ca.Country.Id == exitPoint.Country.Id), exitPoint);

            var entryPoint = entryOrExitPoints.OrderBy(ep => ep.Country.Name)
                .First(ep => ep.Country.IsEuropeanUnionMember && ep.Country.Id != exitPoint.Country.Id);
            var stateOfImport = new StateOfImport(entryPoint.Country,
                competentAuthorities.First(ca => ca.Country.Id == entryPoint.Country.Id), entryPoint);

            transportRoute.SetStateOfExportForNotification(stateOfExport);
            transportRoute.SetStateOfImportForNotification(stateOfImport);

            return transportRoute;
        }
Esempio n. 18
0
        public void SetEntryCustomsOffice_Required_Sets()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                                                  europeanEntryOrExitPoints1[0]);

            var transitState = new TransitState(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0],
                                                nonEuEntryOrExitPoints1[1], 1);

            var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2,
                                                  europeanEntryOrExitPoints2[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);
            transportRoute.AddTransitStateToNotification(transitState);

            transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test", "test", europeanCountry1));

            Assert.Equal("test", transportRoute.EntryCustomsOffice.Name);
            Assert.Equal("test", transportRoute.EntryCustomsOffice.Address);
            Assert.Equal(europeanCountry1.Id, transportRoute.EntryCustomsOffice.Country.Id);
        }
Esempio n. 19
0
        public static TransportRoute CreateCompleted(Guid id, Guid notificationId,
                                                     IList <EntryOrExitPoint> entryOrExitPoints, IList <CompetentAuthority> competentAuthorities,
                                                     ITransportRouteValidator validator)
        {
            var transportRoute = new TransportRoute(notificationId);

            EntityHelper.SetEntityId(transportRoute, id);

            var exitPoint =
                entryOrExitPoints.OrderBy(ep => ep.Country.Name).First(ep => ep.Country.IsEuropeanUnionMember);
            var stateOfExport = new StateOfExport(exitPoint.Country,
                                                  competentAuthorities.First(ca => ca.Country.Id == exitPoint.Country.Id), exitPoint);

            var entryPoint = entryOrExitPoints.OrderBy(ep => ep.Country.Name)
                             .First(ep => ep.Country.IsEuropeanUnionMember && ep.Country.Id != exitPoint.Country.Id);
            var stateOfImport = new StateOfImport(entryPoint.Country,
                                                  competentAuthorities.First(ca => ca.Country.Id == entryPoint.Country.Id), entryPoint);

            transportRoute.SetStateOfExportForNotification(stateOfExport, validator);
            transportRoute.SetStateOfImportForNotification(stateOfImport, validator);

            return(transportRoute);
        }
        public SetExitCustomsOfficeForNotificationByIdHandlerTests()
        {
            this.context = new TestIwsContext();
            var repository = A.Fake <ITransportRouteRepository>();

            anyNotification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 0);
            EntityHelper.SetEntityId(anyNotification, notificationId);

            transport = new TransportRoute(notificationId);

            context.NotificationApplications.Add(anyNotification);
            context.TransportRoutes.Add(transport);

            country      = CountryFactory.Create(AnyGuid);
            nonEuCountry = CountryFactory.Create(new Guid("606ECF5A-6571-4803-9CCA-7E1AF82D147A"), "test", false);

            context.Countries.AddRange(new[]
            {
                country,
                nonEuCountry
            });

            stateOfExport = new StateOfExport(country,
                                              CompetentAuthorityFactory.Create(AnyGuid, country),
                                              EntryOrExitPointFactory.Create(AnyGuid, country));

            stateOfImportNonEu = new StateOfImport(nonEuCountry,
                                                   CompetentAuthorityFactory.Create(new Guid("5E4F1F22-5054-449B-9EC7-933A43BB5D6D"), nonEuCountry),
                                                   EntryOrExitPointFactory.Create(new Guid("9781324F-17B8-4009-89B2-C18963E3E6E1"), nonEuCountry));

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport);

            this.handler   = new SetExitCustomsOfficeForNotificationByIdHandler(context, repository);
            this.validator = A.Fake <ITransportRouteValidator>();
            A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true);
            A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(stateOfImportNonEu, stateOfExport)).Returns(true);
        }
Esempio n. 21
0
 public TransportRouteTests()
 {
     stateOfImport = new StateOfImport(anyGuid, anyGuid);
     stateOfExport = new StateOfExport(anyGuid, anyGuid, anyGuid);
 }
 public bool IsImportAndExportStatesCombinationValid(StateOfImport importState, StateOfExport exportState)
 {
     return(true);
 }
        public void CanCreateStateOfImport()
        {
            var stateOfImport = new StateOfImport(anyGuid, anyGuid);

            Assert.IsType<StateOfImport>(stateOfImport);
        }
        public void CustomsOfficesRequired_StateOfImportOutsideEU_Exit()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.Exit, result);
        }
Esempio n. 25
0
 private void SetStateOfImport(StateOfImport stateOfImport)
 {
     ObjectInstantiator <TransportRoute> .SetProperty(x => x.StateOfImport, stateOfImport, transportRoute);
 }
        public void CustomsOfficesRequired_StateOfTransitInsideEUImportOutside_Exit()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(nonEuCountry2, nonEuCompetentAuthority2,
                nonEuEntryOrExitPoints2[0]);

            var transitState = new TransitState(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0],
                europeanEntryOrExitPoints2[1], 1);

            transportRoute.AddTransitStateToNotification(transitState);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.Exit, result);
        }
        public void SetEntryCustomsOffice_Required_OverwritesPrevious()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);

            var transitState = new TransitState(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0],
                nonEuEntryOrExitPoints1[1], 1);

            var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2,
                europeanEntryOrExitPoints2[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);
            transportRoute.AddTransitStateToNotification(transitState);

            transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test", "test", europeanCountry1));

            transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test2", "test2", europeanCountry2));

            Assert.Equal("test2", transportRoute.EntryCustomsOffice.Name);
            Assert.Equal("test2", transportRoute.EntryCustomsOffice.Address);
            Assert.Equal(europeanCountry2.Id, transportRoute.EntryCustomsOffice.Country.Id);
        }
Esempio n. 28
0
 public StateOfImportViewModel(StateOfImport stateOfImport)
 {
     CompetentAuthorityId = stateOfImport.CompetentAuthorityId;
     EntryPointId         = stateOfImport.EntryPointId;
 }
 public StateOfImportViewModel(StateOfImport stateOfImport)
 {
     CompetentAuthorityId = stateOfImport.CompetentAuthorityId;
     EntryPointId = stateOfImport.EntryPointId;
 }
 private void SetStateOfImport(StateOfImport stateOfImport)
 {
     ObjectInstantiator<TransportRoute>.SetProperty(x => x.StateOfImport, stateOfImport, transportRoute);
 }
        public void SetStateOfImport_SameCountryToStateOfExport_Throws()
        {
            // Arrange
            var exportCountry = countries[0];

            var exportCompetentAuthority = CompetentAuthorityFactory.Create(guids[0], exportCountry);
            var exportExitPoint = EntryOrExitPointFactory.Create(guids[0], exportCountry);

            var importCompetentAuthority = CompetentAuthorityFactory.Create(guids[1], exportCountry);
            var importExitPoint = EntryOrExitPointFactory.Create(guids[1], exportCountry);

            var stateOfExport = new StateOfExport(exportCountry,
                exportCompetentAuthority,
                exportExitPoint);

            var stateOfImport = new StateOfImport(exportCountry,
                importCompetentAuthority,
                importExitPoint);

            // Act
            transportRoute.SetStateOfExportForNotification(stateOfExport);

            // Assert
            Assert.Throws<InvalidOperationException>(() => transportRoute.SetStateOfImportForNotification(stateOfImport));
        }
Esempio n. 32
0
        public void RemoveOnlyNonEUTransitState_RaisesAllTransitStatesInEUEvent()
        {
            var importCountry  = CountryFactory.Create(new Guid("EFFD18F8-32F1-48FE-8513-0FD5E45EF730"));
            var exportCountry  = CountryFactory.Create(new Guid("FA92F4B9-CE86-44D7-8554-23D3B07A5269"));
            var transitCountry = CountryFactory.Create(new Guid("873F6164-3DFE-481E-B372-9BD530304E70"), isEuMember: false);

            var transitState = new TransitState(
                transitCountry,
                new TestableCompetentAuthority()
            {
                Country = transitCountry
            },
                new TestableEntryOrExitPoint()
            {
                Country = transitCountry
            },
                new TestableEntryOrExitPoint()
            {
                Country = transitCountry
            },
                4);

            var transitStateId = new Guid("0BE78BE8-F666-4775-B3DA-7C058BFE4F4D");

            EntityHelper.SetEntityId(transitState, transitStateId);

            var stateOfImport = new StateOfImport(
                importCountry,
                new TestableCompetentAuthority()
            {
                Country = importCountry
            },
                new TestableEntryOrExitPoint()
            {
                Country = importCountry
            });
            var stateOfExport = new StateOfExport(
                exportCountry,
                new TestableCompetentAuthority()
            {
                Country = exportCountry
            },
                new TestableEntryOrExitPoint()
            {
                Country = exportCountry
            });

            var validatorMock = A.Fake <ITransportRouteValidator>();

            A.CallTo(() => validatorMock.IsImportAndExportStatesCombinationValid(stateOfImport, null)).Returns(true);
            A.CallTo(() => validatorMock.IsImportAndExportStatesCombinationValid(stateOfImport, stateOfExport)).Returns(true);

            transportRoute.SetStateOfImportForNotification(
                stateOfImport,
                validatorMock);

            transportRoute.SetStateOfExportForNotification(
                stateOfExport,
                validatorMock);

            transportRoute.AddTransitStateToNotification(transitState);

            transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("entry", "entry", importCountry));
            transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("exit", "exit", exportCountry));

            transportRoute.RemoveTransitState(transitStateId);
        }
        public void SetStateOfImport_DifferentCountryToStateOfExport_SetsSuccessfully()
        {
            var exportCountry = countries[0];
            var importCountry = countries[1];

            var exportCompetentAuthority = GetTestCompetentAuthority(exportCountry);
            var exportExitPoint = GetTestEntryOrExitPoint(exportCountry);

            var importCompetentAuthority = GetTestCompetentAuthority(importCountry);
            var importExitPoint = GetTestEntryOrExitPoint(importCountry);

            var stateOfExport = new StateOfExport(exportCountry,
                exportCompetentAuthority,
                exportExitPoint);

            var stateOfImport = new StateOfImport(importCountry,
                importCompetentAuthority,
                importExitPoint);

            // Act
            transportRoute.SetStateOfExportForNotification(stateOfExport);
            transportRoute.SetStateOfImportForNotification(stateOfImport);

            // Assert
            Assert.Equal(importCountry.Id, transportRoute.StateOfImport.Country.Id);
        }
 public TransportRouteTests()
 {
     stateOfImport = new StateOfImport(anyGuid, anyGuid);
     stateOfExport = new StateOfExport(anyGuid, anyGuid, anyGuid);
 }
        public void CustomsOfficesRequired_ImportAndExportInsideEU_None()
        {
            var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1,
                europeanEntryOrExitPoints1[0]);
            var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2,
                europeanEntryOrExitPoints2[0]);

            SetStateOfExport(stateOfExport);
            SetStateOfImport(stateOfImport);

            var result = requiredCustomsOffices.GetForTransportRoute(transportRoute);

            Assert.Equal(CustomsOffices.None, result);
        }
        private StateOfImport GenerateStateOfImport(Draft.StateOfImport stateOfImport,
            TransportRouteLookups lookups)
        {
            var returnValue = new StateOfImport();

            if (stateOfImport.CompetentAuthorityId.HasValue)
            {
                var competentAuthority = lookups.GetCompetentAuthority(stateOfImport.CompetentAuthorityId);

                returnValue.CompetentAuthorityCode = competentAuthority.Code;
                returnValue.CompetentAuthorityName = competentAuthority.Name;
            }

            if (stateOfImport.EntryPointId.HasValue)
            {
                returnValue.EntryPointName = lookups.GetEntryOrExitPoint(stateOfImport.EntryPointId).Name;
            }

            return returnValue;
        }
Esempio n. 37
0
        public void CanCreateStateOfImport()
        {
            var stateOfImport = new StateOfImport(anyGuid, anyGuid);

            Assert.IsType <StateOfImport>(stateOfImport);
        }