Exemple #1
0
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());
            var index = new Index();

            var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel;
            var view            = index.RenderAsHtml(searchViewModel);

            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("Keywords").ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            view.GetElementbyId("Location").Should().NotBeNull();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("Location").ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            view.GetElementbyId("loc-within").Should().NotBeNull();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" active").Should().BeFalse();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("loc-within").ParentNode.ParentNode.Attributes["class"].Value.Contains(" tab2").Should().BeFalse();

            //Shares parent with loc-within here.
            view.GetElementbyId("apprenticeship-level").Should().NotBeNull();

            view.GetElementbyId("search-button").Should().NotBeNull();
            view.GetElementbyId("search-button").Attributes["class"].Value.Contains(" tab1").Should().BeTrue();
            view.GetElementbyId("search-button").Attributes["class"].Value.Contains(" active").Should().BeFalse();

            view.GetElementbyId("browse-button").Should().NotBeNull();
            view.GetElementbyId("browse-button").Attributes["class"].Value.Contains(" tab2").Should().BeFalse();
            view.GetElementbyId("browse-button").Attributes["class"].Value.Contains(" active").Should().BeFalse();
        }
Exemple #2
0
        public CreateOrderService(ICommandBus commandBus,
                                  IAccountDao accountDao,
                                  IServerSettings serverSettings,
                                  ReferenceDataService referenceDataService,
                                  IIBSServiceProvider ibsServiceProvider,
                                  IRuleCalculator ruleCalculator,
                                  IAccountChargeDao accountChargeDao,
                                  ICreditCardDao creditCardDao,
                                  IOrderDao orderDao,
                                  IPromotionDao promotionDao,
                                  IEventSourcedRepository <Promotion> promoRepository,
                                  ITaxiHailNetworkServiceClient taxiHailNetworkServiceClient,
                                  IPaymentService paymentService,
                                  IPayPalServiceFactory payPalServiceFactory,
                                  IOrderPaymentDao orderPaymentDao,
                                  IFeesDao feesDao,
                                  ILogger logger,
                                  IIbsCreateOrderService ibsCreateOrderService)
            : base(serverSettings, commandBus, accountChargeDao, paymentService, creditCardDao,
                   ibsServiceProvider, promotionDao, promoRepository, orderPaymentDao, accountDao,
                   payPalServiceFactory, logger, taxiHailNetworkServiceClient, ruleCalculator,
                   feesDao, referenceDataService, orderDao)
        {
            _commandBus                   = commandBus;
            _accountDao                   = accountDao;
            _referenceDataService         = referenceDataService;
            _serverSettings               = serverSettings;
            _orderDao                     = orderDao;
            _taxiHailNetworkServiceClient = taxiHailNetworkServiceClient;
            _logger = logger;
            _ibsCreateOrderService = ibsCreateOrderService;
            _resources             = new Resources.Resources(_serverSettings);

            _taxiHailNetworkHelper = new TaxiHailNetworkHelper(_serverSettings, _taxiHailNetworkServiceClient, _commandBus, _logger);
        }
Exemple #3
0
 public SignUpModel(ReferenceDataService referenceDataService, ProspectSaveService prospectSaveService, IConfiguration config, ILogger <SignUpModel> logger)
 {
     this.configuration        = config;
     this.logger               = logger;
     this.prospectSaveService  = prospectSaveService;
     this.referenceDataService = referenceDataService;
 }
Exemple #4
0
        public JsonResult GenerateReferenceData()
        {
            var referenceDataService = new ReferenceDataService();
            var elapsedTime          = PerformanceTools.MeasureElapsedTime(() => referenceDataService.Generate());

            return(Json(new BaseApiResponse {
                ElapsedTime = elapsedTime
            }));
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());

            var categories = new categories();

            var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("category-load-failed").Should().NotBeNull();
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());

            var categories = new categoriesAndSubCategories();

            var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeTrue();
            view.GetElementbyId("category-load-failed").Should().NotBeNull();
        }
Exemple #7
0
        public void BlacklistedCategoryCodes()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories()).Returns(GetCategories);

            var response = Mediator.Index(ApprenticeshipSearchMode.Category);

            var categories = response.ViewModel.Categories;

            categories.Count.Should().Be(3);
            categories.Any(c => c.CodeName == "00").Should().BeFalse();
            categories.Any(c => c.CodeName == "99").Should().BeFalse();
        }
        public async Task GetCountries_CountriesFound_ReturnsCountries(
            [Frozen] Mock <IReferenceDataApiClient> referenceDataApiClient,
            List <CountryRegion> countries,
            ReferenceDataService sut
            )
        {
            //Arrange
            referenceDataApiClient.Setup(x => x.GetCountriesAsync())
            .ReturnsAsync(countries);

            //Act
            var response = await sut.GetCountriesAsync();

            //Assert
            response.Count.Should().Be(3);
        }
        public void GetContactTypes_NoContactTypesFound_ReturnsContactTypes(
            [Frozen] Mock <IReferenceDataApiClient> referenceDataApiClient,
            ReferenceDataService sut
            )
        {
            //Arrange
            referenceDataApiClient.Setup(x => x.GetContactTypesAsync())
            .ReturnsAsync((List <ContactType>)null);

            //Act
            Func <Task> func = async() => await sut.GetContactTypesAsync();

            //Assert
            func.Should().Throw <ArgumentNullException>()
            .WithMessage("Value cannot be null. (Parameter 'contactTypes')");
        }
        public async Task GetAddressTypes_AddressTypesFound_ReturnsAddressTypes(
            [Frozen] Mock <IReferenceDataApiClient> referenceDataApiClient,
            List <AddressType> addressTypes,
            ReferenceDataService sut
            )
        {
            //Arrange
            referenceDataApiClient.Setup(x => x.GetAddressTypesAsync())
            .ReturnsAsync(addressTypes);

            //Act
            var response = await sut.GetAddressTypesAsync();

            //Assert
            response.Count.Should().Be(3);
        }
        public async Task GetStatesProvinces_StatesProvincesFound_ReturnsStatesProvinces(
            [Frozen] Mock <IReferenceDataApiClient> referenceDataApiClient,
            List <StateProvince> statesProvinces,
            ReferenceDataService sut
            )
        {
            //Arrange
            referenceDataApiClient.Setup(x => x.GetStatesProvincesAsync(
                                             It.IsAny <string>()
                                             ))
            .ReturnsAsync(statesProvinces);

            //Act
            var response = await sut.GetStatesProvincesAsync();

            //Assert
            response.Count.Should().Be(3);
        }
        public void GetStatesProvinces_NoStatesProvincesFound_ReturnsStatesProvinces(
            [Frozen] Mock <IReferenceDataApiClient> referenceDataApiClient,
            ReferenceDataService sut
            )
        {
            //Arrange
            referenceDataApiClient.Setup(x => x.GetStatesProvincesAsync(
                                             It.IsAny <string>()
                                             ))
            .ReturnsAsync((List <StateProvince>)null);

            //Act
            Func <Task> func = async() => await sut.GetStatesProvincesAsync();

            //Assert
            func.Should().Throw <ArgumentNullException>()
            .WithMessage("Value cannot be null. (Parameter 'statesProvinces')");
        }
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());
            var searchUpdate = new searchUpdate();

            var searchViewModel        = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;
            var searchResultsViewModel = Mediator.Results(null, searchViewModel).ViewModel;
            var view = searchUpdate.RenderAsHtml(searchResultsViewModel.VacancySearch);

            view.GetElementbyId("Keywords").Should().BeNull();
            view.GetElementbyId("Location").Should().NotBeNull();
            view.GetElementbyId("loc-within").Should().NotBeNull();
            view.GetElementbyId("apprenticeship-level").Should().NotBeNull();
            view.GetElementbyId("search-button").Should().NotBeNull();

            var createNewSearchLink = view.GetElementbyId("start-again-link");

            createNewSearchLink.Should().NotBeNull();
            createNewSearchLink.OuterHtml.Should().Contain("SearchMode=Category");
        }
Exemple #14
0
        internal BaseCreateOrderService(IServerSettings serverSettings,
                                        ICommandBus commandBus,
                                        IAccountChargeDao accountChargeDao,
                                        IPaymentService paymentService,
                                        ICreditCardDao creditCardDao,
                                        IIBSServiceProvider ibsServiceProvider,
                                        IPromotionDao promotionDao,
                                        IEventSourcedRepository <Promotion> promoRepository,
                                        IOrderPaymentDao orderPaymentDao,
                                        IAccountDao accountDao,
                                        IPayPalServiceFactory payPalServiceFactory,
                                        ILogger logger,
                                        ITaxiHailNetworkServiceClient taxiHailNetworkServiceClient,
                                        IRuleCalculator ruleCalculator,
                                        IFeesDao feesDao,
                                        ReferenceDataService referenceDataService,
                                        IOrderDao orderDao)
        {
            _serverSettings               = serverSettings;
            _commandBus                   = commandBus;
            _accountChargeDao             = accountChargeDao;
            _paymentService               = paymentService;
            _creditCardDao                = creditCardDao;
            _ibsServiceProvider           = ibsServiceProvider;
            _promotionDao                 = promotionDao;
            _promoRepository              = promoRepository;
            _accountDao                   = accountDao;
            _logger                       = logger;
            _taxiHailNetworkServiceClient = taxiHailNetworkServiceClient;
            _ruleCalculator               = ruleCalculator;
            _feesDao                      = feesDao;
            _referenceDataService         = referenceDataService;
            _orderDao                     = orderDao;

            _resources             = new Resources.Resources(_serverSettings);
            _taxiHailNetworkHelper = new TaxiHailNetworkHelper(_serverSettings, _taxiHailNetworkServiceClient, _commandBus, _logger);

            PaymentHelper = new CreateOrderPaymentHelper(serverSettings, commandBus, paymentService, orderPaymentDao, payPalServiceFactory);
        }
        /// <summary>
        /// Setups the data.
        /// </summary>
        private void SetupData()
        {
            Domain.Dependencies.Register();
            DataAccess.Dependencies.Register();

            Workstation ws = DIContainer.Instance.Resolve<Workstation>();

            ws.Port = new Port { PortId = "1" };
            ws.Ship = new Ship { ShipId = "1" };
            ws.GangwayLocation = new GangwayLocation { LocationId = "1" };
            ws.GangwayServiceBaseAddress = "http://Localhost/";
            ws.ConnectionMode = ConnectionMode.Online;
            ws.ConfigurationServiceBaseAddress = "http://Localhost/";
            ws.AuthenticationServiceBaseAddress = "http://Localhost/";
            ws.AuthorizationServiceBaseAddress = "http://Localhost/";
            var intCollection = new Collection<int>();
            intCollection.Add(0);
            var brand = new Brand { BrandId = "3", Name = "Carnival Breeze", MediaItemAddress = "http://172.26.248.122/ImagingMediaService/MediaItems/23" };
            brand.AssignPortIds(intCollection);
            ws.Brand = brand;

            ////this.repository = new Mock<IRepository>();
            ////this.embarkationStatisticsRepositoryMock = new Mock<EmbarkationStatisticsRepository>();
            ////this.personServiceRepositoryMock = new Mock<PersonServiceRepository>();
            ////this.photoCaptureRepositoryMock = new Mock<PhotoCaptureRepository>();
            ////this.shipTimeRepositoryMock = new Mock<ShipTimeRepository>();
            this.referenceDataRepositoryMock = new Mock<ReferenceDataRepository>();
            ////this.gangwayEventRepositoryMock = new Mock<GangwayEventRepository>();
            ////this.referenceDataClient = new Mock<IReferenceDataClient>();
            ////this.shipClient = new Mock<IShipClient>();

            ////DIContainer.Instance.RegisterInstance<IReferenceDataClient>(this.referenceDataClient.Object);
            ////DIContainer.Instance.RegisterInstance<IShipClient>(this.shipClient.Object);

            ////DIContainer.Instance.RegisterInstance<IRepository>(this.repository.Object);
            DIContainer.Instance.RegisterInstance<ReferenceDataRepository>(this.referenceDataRepositoryMock.Object);
            ////DIContainer.Instance.RegisterInstance<EmbarkationStatisticsRepository>(this.embarkationStatisticsRepositoryMock.Object);
            ////DIContainer.Instance.RegisterInstance<GangwayEventRepository>(this.gangwayEventRepositoryMock.Object);
            ////DIContainer.Instance.RegisterInstance<PhotoCaptureRepository>(this.photoCaptureRepositoryMock.Object);
            ////DIContainer.Instance.RegisterInstance<PersonServiceRepository>(this.personServiceRepositoryMock.Object);
            ////DIContainer.Instance.RegisterInstance<ShipTimeRepository>(this.shipTimeRepositoryMock.Object);
            this.service = new ReferenceDataService();
            this.referenceDataRepositoryMock.Setup(data => data.RetrieveReferenceDataAsync()).Returns(Task.FromResult(this.referenceData));
            this.referenceDataRepositoryMock.Setup(data => data.RetrieveShipInfoAsync("5", false)).Returns(Task.FromResult(this.shipInfo));
            this.referenceDataRepositoryMock.Setup(data => data.RetrieveShipListAsync("3", "5", "1")).Returns(Task.FromResult(this.shipList));
            ////var referenceData = @"{""Countries"":[{""CountryId"":""1"",""Code"":""AF"",""Name"":""Afghanistan"",""CountryFlagAddress"":""http://devweb03.decurtis.com/ImagingMediaService/MediaItems/1""}]}";

            ////this.referenceDataClient.Setup(data => data.RetrieveReferenceDataAsync()).Returns(Task.FromResult(referenceData));
            ////this.referenceDataClient.Setup(data => data.RetrieveShipInfoAsync("5")).Returns(Task.FromResult(@"{""PreviousPageAddress"":null,""NextPageAddress"":null,""Items"":[{""ShipId"":""5"",""BrandId"":""3"",""Code"":""H6403"",""Name"":""Carnival Breeze"",""MediaItemAddress"":""http://devweb03.decurtis.com/ImagingMediaService/MediaItems/304004""}],""TotalResults"":1}"));

            ////this.shipClient.Setup(data => data.RetrieveShipListAsync(It.IsNotNull<string>(), It.IsAny<string>(), It.IsAny<string>(), 0, 0)).Returns(this.RetrieveShipAsync());
        }
Exemple #16
0
        public void TestKeywordSearchModification()
        {
            const string selectedCategoryCode        = "2";
            const string selectedCategorySubCategory = "2_2";

            ReferenceDataService.Setup(rds => rds.GetCategories()).Returns(new List <Category>
            {
                new Category
                {
                    CodeName      = "1",
                    SubCategories = new List <Category>
                    {
                        new Category {
                            CodeName = "1_1"
                        },
                        new Category {
                            CodeName = "1_2"
                        }
                    }
                },
                new Category
                {
                    CodeName      = selectedCategoryCode,
                    SubCategories = new List <Category>
                    {
                        new Category {
                            CodeName = "2_1"
                        },
                        new Category {
                            CodeName = selectedCategorySubCategory
                        }
                    }
                }
            });

            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Keywords     = AKeyword,
                Location     = ACityWithOneSuggestedLocation,
                LocationType = ApprenticeshipLocationType.NonNational,
                Category     = selectedCategoryCode,
                //Select Sub Categories from a different category than the one selected plus a valid one
                SubCategories = new[]
                {
                    "1_1",
                    "1_2",
                    selectedCategorySubCategory
                },
                SearchMode = ApprenticeshipSearchMode.Keyword
            };

            var response = Mediator.Results(searchViewModel);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.Ok, true);

            //The search sent to the search provider should have been modified based on the search mode
            _searchSentToSearchProvider.Should().NotBeNull();
            _searchSentToSearchProvider.Keywords.Should().Be(AKeyword);
            _searchSentToSearchProvider.Location.Should().Be(ACityWithOneSuggestedLocation);
            _searchSentToSearchProvider.LocationType.Should().Be(ApprenticeshipLocationType.NonNational);
            _searchSentToSearchProvider.Categories.Should().BeNull();
            _searchSentToSearchProvider.Category.Should().BeNullOrEmpty();
            _searchSentToSearchProvider.SubCategories.Should().BeNull();
            _searchSentToSearchProvider.SearchMode.Should().Be(ApprenticeshipSearchMode.Keyword);

            //But the returned search should be the original search the user submitted so as not to lose any of their changes
            var returnedSearch = response.ViewModel.VacancySearch;

            returnedSearch.Should().NotBeNull();
            returnedSearch.Keywords.Should().Be(AKeyword);
            returnedSearch.Location.Should().Be(ACityWithOneSuggestedLocation);
            returnedSearch.LocationType.Should().Be(ApprenticeshipLocationType.NonNational);
            returnedSearch.Categories.Should().NotBeNull();
            returnedSearch.Categories.Count.Should().Be(2);
            returnedSearch.Category.Should().Be(selectedCategoryCode);
            returnedSearch.SubCategories.Length.Should().Be(1);
            returnedSearch.SubCategories[0].Should().Be(selectedCategorySubCategory);
            returnedSearch.SearchMode.Should().Be(ApprenticeshipSearchMode.Keyword);
        }
Exemple #17
0
        private static void FirstTask()
        {
            var referenceDataService = new ReferenceDataService();

            referenceDataService.Generate();
        }