示例#1
0
 public TransitStateMap(ICountryRepository countryRepository,
                        IEntryOrExitPointRepository pointRepository,
                        ICompetentAuthorityRepository competentAuthorityRepository)
 {
     this.countryRepository            = countryRepository;
     this.pointRepository              = pointRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
 }
        public GetCompetentAuthoritiesAndEntryPointsByCountryIdHandlerTests()
        {
            entryOrExitPointRepository                = A.Fake <IEntryOrExitPointRepository>();
            intraCountryExportAllowedRepository       = A.Fake <IIntraCountryExportAllowedRepository>();
            unitedKingdomCompetentAuthorityRepository = A.Fake <IUnitedKingdomCompetentAuthorityRepository>();
            var iwsContext = new TestIwsContext();

            var countryWithData      = CountryFactory.Create(countryWithDataId);
            var unitedKingdomCountry = CountryFactory.Create(unitedKingdomCountryId);
            var countryWithNoData    = CountryFactory.Create(countryWithNoDataId);

            competentAuthorities = new[]
            {
                CompetentAuthorityFactory.Create(new Guid("67D2B3B5-298A-4BB5-901C-0C0C80097242"), unitedKingdomCountry),
                CompetentAuthorityFactory.Create(new Guid("5E7CA40F-D7B5-49C3-8850-694D36D52C94"), countryWithData),
                CompetentAuthorityFactory.Create(new Guid("DFD98B0D-F255-4BA0-96A5-527DE9F973E3"), countryWithData)
            };

            A.CallTo(() => unitedKingdomCompetentAuthorityRepository.GetAll()).Returns(new[]
            {
                new TestableUnitedKingdomCompetentAuthority(1, competentAuthorities[0], "something", null)
            });

            var competentAuthorityMapper = new CompetentAuthorityMap();
            var entryOrExitPointMapper   = new EntryOrExitPointMap();

            A.CallTo(() => entryOrExitPointRepository.GetForCountry(countryWithDataId)).Returns(new[]
            {
                EntryOrExitPointFactory.Create(new Guid("FC012C3E-4252-4D62-A8A2-D46DE0FA93B9"), countryWithData),
                EntryOrExitPointFactory.Create(new Guid("9699CC16-6EF1-4889-9598-F4B0511A2038"), countryWithData)
            });

            A.CallTo(() => intraCountryExportAllowedRepository.GetImportCompetentAuthorities(UKCompetentAuthority.England)).Returns(new[]
            {
                new TestableIntraCountryExportAllowed
                {
                    ExportCompetentAuthority   = UKCompetentAuthority.England,
                    ImportCompetentAuthorityId = competentAuthorities[1].Id
                }
            });

            repository = A.Fake <ICompetentAuthorityRepository>();

            A.CallTo(() => repository.GetCompetentAuthorities(countryWithDataId)).Returns(competentAuthorities);

            ids = new Guid[]
            {
                competentAuthorities[1].Id
            };

            A.CallTo(repository).Where(call => call.Method.Name == "GetByIds")
            .WithReturnType <CompetentAuthority[]>()
            .Returns(competentAuthorities);

            handler = new GetCompetentAuthoritiesAndEntryPointsByCountryIdHandler(entryOrExitPointMapper, competentAuthorityMapper, repository, entryOrExitPointRepository, intraCountryExportAllowedRepository, iwsContext, unitedKingdomCompetentAuthorityRepository);
        }
 public GetUnitedKingdomCompetentAuthoritiesAndEntryOrExitPointsHandler(ICountryRepository countryRepository,
                                                                        ICompetentAuthorityRepository competentAuthorityRepository,
                                                                        IEntryOrExitPointRepository entryOrExitPointRepository,
                                                                        IMapper mapper)
 {
     this.countryRepository            = countryRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.entryOrExitPointRepository   = entryOrExitPointRepository;
     this.mapper = mapper;
 }
 public GetTransitStateDataForTransitStatesHandler(ICountryRepository countryRepository,
                                                   ICompetentAuthorityRepository competentAuthorityRepository,
                                                   IEntryOrExitPointRepository entryOrExitPointRepository,
                                                   IMapper mapper)
 {
     this.countryRepository            = countryRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.entryOrExitPointRepository   = entryOrExitPointRepository;
     this.mapper = mapper;
 }
示例#5
0
 public GetCompetentAuthoritiesAndEntryOrExitPointsByCountryIdHandler(IMap <EntryOrExitPoint, EntryOrExitPointData> entryOrExitPointMapper,
                                                                      IMap <CompetentAuthority, CompetentAuthorityData> competentAuthorityMapper,
                                                                      ICompetentAuthorityRepository competentAuthorityRepository,
                                                                      IEntryOrExitPointRepository entryOrExitPointRepository)
 {
     this.entryOrExitPointRepository   = entryOrExitPointRepository;
     this.entryOrExitPointMapper       = entryOrExitPointMapper;
     this.competentAuthorityMapper     = competentAuthorityMapper;
     this.competentAuthorityRepository = competentAuthorityRepository;
 }
 public GetTransitStateWithTransportRouteDataByNotificationIdHandler(IwsContext context,
                                                                     IMapper mapper,
                                                                     ITransportRouteRepository transportRouteRepository,
                                                                     ICompetentAuthorityRepository competentAuthorityRepository,
                                                                     ICountryRepository countryRepository)
 {
     this.context = context;
     this.mapper  = mapper;
     this.transportRouteRepository     = transportRouteRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.countryRepository            = countryRepository;
 }
 public GetInternalUserCompetentAuthorityHandler(IInternalUserRepository internalUserRepository,
                                                 ICountryRepository countryRepository,
                                                 ICompetentAuthorityRepository competentAuthorityRepository,
                                                 IMapper mapper,
                                                 IUserContext userContext)
 {
     this.internalUserRepository       = internalUserRepository;
     this.countryRepository            = countryRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.mapper      = mapper;
     this.userContext = userContext;
 }
示例#8
0
 public StateOfExportMap(ICountryRepository countryRepository, ICompetentAuthorityRepository competentAuthorityRepository,
                         IEntryOrExitPointRepository entryOrExitPointRepository,
                         IMap <Country, CountryData> countryMap,
                         IMap <CompetentAuthority, CompetentAuthorityData> competentAuthorityMap,
                         IMap <EntryOrExitPoint, EntryOrExitPointData> entryOrExitPointMap)
 {
     this.countryRepository            = countryRepository;
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.entryOrExitPointRepository   = entryOrExitPointRepository;
     this.countryMap            = countryMap;
     this.competentAuthorityMap = competentAuthorityMap;
     this.entryOrExitPointMap   = entryOrExitPointMap;
 }
        public StateOfExportValidatorTests()
        {
            entryOrExitPointRepository = A.Fake<IEntryOrExitPointRepository>();
            competentAuthorityRepository = A.Fake<ICompetentAuthorityRepository>();

            validator = new StateOfExportValidator(entryOrExitPointRepository, competentAuthorityRepository);

            A.CallTo(() => entryOrExitPointRepository.GetById(TestableEntryOrExitPoint.Calais.Id))
                .Returns(TestableEntryOrExitPoint.Calais);
            A.CallTo(() => competentAuthorityRepository.GetById(TestableCompetentAuthority.FrenchAuthorityArdeche.Id))
                .Returns(TestableCompetentAuthority.FrenchAuthorityArdeche);
            A.CallTo(() => competentAuthorityRepository.GetById(TestableCompetentAuthority.EnvironmentAgency.Id))
                .Returns(TestableCompetentAuthority.EnvironmentAgency);
            A.CallTo(() => entryOrExitPointRepository.GetById(TestableEntryOrExitPoint.Dover.Id))
                .Returns(TestableEntryOrExitPoint.Dover);
        }
        public StateOfExportValidatorTests()
        {
            entryOrExitPointRepository   = A.Fake <IEntryOrExitPointRepository>();
            competentAuthorityRepository = A.Fake <ICompetentAuthorityRepository>();

            validator = new StateOfExportValidator(entryOrExitPointRepository, competentAuthorityRepository);

            A.CallTo(() => entryOrExitPointRepository.GetById(TestableEntryOrExitPoint.Calais.Id))
            .Returns(TestableEntryOrExitPoint.Calais);
            A.CallTo(() => competentAuthorityRepository.GetById(TestableCompetentAuthority.FrenchAuthorityArdeche.Id))
            .Returns(TestableCompetentAuthority.FrenchAuthorityArdeche);
            A.CallTo(() => competentAuthorityRepository.GetById(TestableCompetentAuthority.EnvironmentAgency.Id))
            .Returns(TestableCompetentAuthority.EnvironmentAgency);
            A.CallTo(() => entryOrExitPointRepository.GetById(TestableEntryOrExitPoint.Dover.Id))
            .Returns(TestableEntryOrExitPoint.Dover);
        }
 public GetCompetentAuthoritiesAndEntryPointsByCountryIdHandler(IMap <EntryOrExitPoint, EntryOrExitPointData> entryOrExitPointMapper,
                                                                IMap <CompetentAuthority, CompetentAuthorityData> competentAuthorityMapper,
                                                                ICompetentAuthorityRepository competentAuthorityRepository,
                                                                IEntryOrExitPointRepository entryOrExitPointRepository,
                                                                IIntraCountryExportAllowedRepository intraCountryExportAllowedRepository,
                                                                IwsContext context,
                                                                IUnitedKingdomCompetentAuthorityRepository unitedKingdomCompetentAuthorityRepository)
 {
     this.entryOrExitPointRepository          = entryOrExitPointRepository;
     this.entryOrExitPointMapper              = entryOrExitPointMapper;
     this.competentAuthorityMapper            = competentAuthorityMapper;
     this.competentAuthorityRepository        = competentAuthorityRepository;
     this.intraCountryExportAllowedRepository = intraCountryExportAllowedRepository;
     this.context = context;
     this.unitedKingdomCompetentAuthorityRepository = unitedKingdomCompetentAuthorityRepository;
 }
示例#12
0
        public StateOfExportValidator(IEntryOrExitPointRepository entryOrExitPointRepository,
                                      ICompetentAuthorityRepository competentAuthorityRepository)
        {
            this.entryOrExitPointRepository   = entryOrExitPointRepository;
            this.competentAuthorityRepository = competentAuthorityRepository;

            RuleFor(x => x.CountryId)
            .NotNull()
            .WithLocalizedMessage(() => StateOfExportValidatorResources.StateOfExportCountryNotNull);

            RuleFor(x => x.ExitPointId)
            .MustAsync(BeInSameCountry)
            .WithLocalizedMessage(() => StateOfExportValidatorResources.ExportExitPointMustBeInSameCountry);

            RuleFor(x => x.CompetentAuthorityId)
            .MustAsync(BeInCountry)
            .WithLocalizedMessage(() => StateOfExportValidatorResources.CompetentAuthorityMustBeInSameCountry);
        }
 public GetStateOfImportWithTransportRouteDataByNotificationIdHandler(IwsContext context,
                                                                      IMapper mapper,
                                                                      ITransportRouteRepository transportRouteRepository,
                                                                      ICompetentAuthorityRepository competentAuthorityRepository,
                                                                      ICountryRepository countryRepository,
                                                                      IIntraCountryExportAllowedRepository intraCountryExportAllowedRepository,
                                                                      INotificationApplicationRepository notificationApplicationRepository,
                                                                      IRequestHandler <GetCompetentAuthoritiesAndEntryPointsByCountryId, CompetentAuthorityAndEntryOrExitPointData> getCompetentAuthoritiesAndEntryPointsByCountryIdHandler,
                                                                      IUnitedKingdomCompetentAuthorityRepository unitedKingdomCompetentAuthorityRepository)
 {
     this.context = context;
     this.mapper  = mapper;
     this.transportRouteRepository            = transportRouteRepository;
     this.competentAuthorityRepository        = competentAuthorityRepository;
     this.countryRepository                   = countryRepository;
     this.intraCountryExportAllowedRepository = intraCountryExportAllowedRepository;
     this.notificationApplicationRepository   = notificationApplicationRepository;
     this.getCompetentAuthoritiesAndEntryPointsByCountryIdHandler = getCompetentAuthoritiesAndEntryPointsByCountryIdHandler;
     this.unitedKingdomCompetentAuthorityRepository = unitedKingdomCompetentAuthorityRepository;
 }
示例#14
0
        public TransitStateValidator(IEntryOrExitPointRepository entryOrExitPointRepository,
                                     ICompetentAuthorityRepository competentAuthorityRepository)
        {
            this.competentAuthorityRepository = competentAuthorityRepository;
            this.entryOrExitPointRepository   = entryOrExitPointRepository;

            RuleFor(x => x.CountryId)
            .NotNull()
            .WithLocalizedMessage(() => TransitStateValidatorResources.CountryNotNull);

            RuleFor(x => x.EntryPointId)
            .MustAsync(BeEnteringSameCountry)
            .WithLocalizedMessage(() => TransitStateValidatorResources.EntryPointMustBeSelectedCountry);

            RuleFor(x => x.ExitPointId)
            .MustAsync(BeExitingSameCountry)
            .WithLocalizedMessage(() => TransitStateValidatorResources.ExitPointMustBeSelectedCountry);

            RuleFor(x => x.CompetentAuthorityId)
            .MustAsync(BeInSameCountry)
            .WithLocalizedMessage(() => TransitStateValidatorResources.CompetentAuthorityMustBeSelectedCountry);
        }
示例#15
0
        public StateOfImportValidator(ICountryRepository countryRepository,
                                      ICompetentAuthorityRepository competentAuthorityRepository,
                                      IEntryOrExitPointRepository entryOrExitPointRepository)
        {
            this.countryRepository            = countryRepository;
            this.competentAuthorityRepository = competentAuthorityRepository;
            this.entryOrExitPointRepository   = entryOrExitPointRepository;

            RuleFor(x => x.CompetentAuthorityId)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotNull()
            .WithLocalizedMessage(() => StateOfImportValidatorResources.StateOfImportCompetentAuthorityNotEmpty)
            .MustAsync(BeACompetentAuthorityInTheUK)
            .WithLocalizedMessage(() => StateOfImportValidatorResources.StateOfImportCompetentAuthorityInUK);

            RuleFor(x => x.EntryPointId)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotNull()
            .WithLocalizedMessage(() => StateOfImportValidatorResources.ImportEntryPointNotEmpty)
            .MustAsync(BeAnEntryPointInTheUK)
            .WithLocalizedMessage(() => StateOfImportValidatorResources.ImportEntryPointInUK);
        }
示例#16
0
 public StateOfImportMap(ICompetentAuthorityRepository competentAuthorityRepository,
                         IEntryOrExitPointRepository pointRepository)
 {
     this.competentAuthorityRepository = competentAuthorityRepository;
     this.pointRepository = pointRepository;
 }