Пример #1
0
        public override void Setup()
        {
            base.Setup();

            SearchProvider.Setup(sp => sp.FindLocation(It.IsAny <string>()))
            .Returns <string>(l => new LocationsViewModel(new[] { new LocationViewModel {
                                                                      Name = l
                                                                  } }));

            var londonVacancies = new[]
            {
                new ApprenticeshipVacancySummaryViewModel {
                    Description = "A London Vacancy"
                }
            };

            var emptyVacancies = new ApprenticeshipVacancySummaryViewModel[0];

            //This order is important. Moq will run though all matches and pick the last one
            ApprenticeshipVacancyProvider.Setup(sp => sp.FindVacancies(It.IsAny <ApprenticeshipSearchViewModel>()))
            .Returns <ApprenticeshipSearchViewModel>(
                svm => new ApprenticeshipSearchResponseViewModel {
                Vacancies = emptyVacancies, VacancySearch = svm
            })
            .Callback <ApprenticeshipSearchViewModel>(svm => { _searchSentToSearchProvider = svm; });
            ApprenticeshipVacancyProvider.Setup(
                sp =>
                sp.FindVacancies(
                    It.Is <ApprenticeshipSearchViewModel>(svm => svm.Location == ACityWithOneSuggestedLocation)))
            .Returns <ApprenticeshipSearchViewModel>(
                svm => new ApprenticeshipSearchResponseViewModel {
                Vacancies = londonVacancies, VacancySearch = svm
            })
            .Callback <ApprenticeshipSearchViewModel>(svm => { _searchSentToSearchProvider = svm; });
        }
Пример #2
0
        public void LocationTypeShouldBeCopiedOver()
        {
            ApprenticeshipVacancyProvider.Setup(sp => sp.FindVacancies(It.IsAny <ApprenticeshipSearchViewModel>()))
            .Callback <ApprenticeshipSearchViewModel>(svm =>
            {
                svm.LocationType            = ApprenticeshipLocationType.National;
                _searchSentToSearchProvider = svm;
            })
            .Returns <ApprenticeshipSearchViewModel>(
                svm =>
                new ApprenticeshipSearchResponseViewModel
            {
                Vacancies     = new ApprenticeshipVacancySummaryViewModel[0],
                VacancySearch = svm
            });

            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Keywords     = AKeyword,
                Location     = ACityWithOneSuggestedLocation,
                LocationType = ApprenticeshipLocationType.NonNational,
                Category     = "1",
                SearchMode   = ApprenticeshipSearchMode.Category
            };

            var response = Mediator.Results(null, searchViewModel);

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

            response.ViewModel.VacancySearch.LocationType.Should().Be(ApprenticeshipLocationType.National);
        }
Пример #3
0
        public void ExactMatchFoundUsingVacancyReference()
        {
            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Keywords = "VAC000123456"
            };

            ApprenticeshipVacancyProvider.Setup(sp => sp.FindVacancies(It.IsAny <ApprenticeshipSearchViewModel>()))
            .Returns(new ApprenticeshipSearchResponseViewModel
            {
                ExactMatchFound = true,
                VacancySearch   = searchViewModel,
                Vacancies       = new List <ApprenticeshipVacancySummaryViewModel>
                {
                    new ApprenticeshipVacancySummaryViewModel
                    {
                        Id = 123456
                    }
                }
            });

            var response = Mediator.Results(null, searchViewModel);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.ExactMatchFound, false, true);
        }
        private ApprenticeshipVacancyProvider GetApprenticeshipVacancyProvider()
        {
            var searchProvider = new ApprenticeshipVacancyProvider(
                _apprenticeshipSearchService.Object,
                _candidateService.Object,
                _apprenticeshipMapper,
                _logService.Object,
                _candidateVacancyService.Object);

            return(searchProvider);
        }
Пример #5
0
        public void Ok()
        {
            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                VacancyStatus = VacancyStatuses.Live
            };

            ApprenticeshipVacancyProvider.Setup(p => p.GetVacancyDetailViewModel(It.IsAny <Guid?>(), It.IsAny <int>())).Returns(vacancyDetailViewModel);

            var response = Mediator.Details(Id, null);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Details.Ok, true);
        }
Пример #6
0
        public void VacancyIsUnavailable_CandidateNotLoggedIn()
        {
            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                VacancyStatus = VacancyStatuses.Unavailable
            };

            ApprenticeshipVacancyProvider.Setup(
                p => p.GetVacancyDetailViewModel(It.IsAny <Guid?>(), It.IsAny <int>())).Returns(vacancyDetailViewModel);

            var response = Mediator.Details(Id, null);

            response.AssertCodeAndMessage(ApprenticeshipSearchMediatorCodes.Details.VacancyNotFound);
        }
        public void Ok()
        {
            //Arrange
            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel();

            ApprenticeshipVacancyProvider.Setup(p => p.IncrementClickThroughFor(It.IsAny <int>()))
            .Returns(vacancyDetailViewModel);

            //Act
            var response = Mediator.RedirectToExternalWebsite(Id);

            //Assert
            response.AssertCode(ApprenticeshipSearchMediatorCodes.RedirectToExternalWebsite.Ok, true);
        }
Пример #8
0
        public void VacancyIsUnavailable_CandidateLoggedInAndHasPreviouslyAppliedForVacancy()
        {
            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                CandidateApplicationStatus = ApplicationStatuses.Submitted,
                VacancyStatus = VacancyStatuses.Unavailable
            };

            ApprenticeshipVacancyProvider.Setup(
                p => p.GetVacancyDetailViewModel(It.IsAny <Guid?>(), It.IsAny <int>())).Returns(vacancyDetailViewModel);

            var response = Mediator.Details(Id, Guid.NewGuid());

            response.AssertCodeAndMessage(ApprenticeshipSearchMediatorCodes.Details.VacancyNotFound);
        }
Пример #9
0
        public void PopulateDistance()
        {
            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                VacancyStatus = VacancyStatuses.Live
            };

            ApprenticeshipVacancyProvider.Setup(p => p.GetVacancyDetailViewModel(It.IsAny <Guid?>(), It.IsAny <int>())).Returns(vacancyDetailViewModel);

            UserDataProvider.Setup(udp => udp.Pop(CandidateDataItemNames.VacancyDistance)).Returns(VacancyDistance);
            UserDataProvider.Setup(udp => udp.Pop(CandidateDataItemNames.LastViewedVacancy)).Returns(VacancyType.Apprenticeship + "_" + Convert.ToString(Id));

            var response = Mediator.Details(Id, null);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Details.Ok, true);
        }
Пример #10
0
        public void VacancyHasError()
        {
            const string message = "The vacancy has an error";

            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                ViewModelMessage = message,
                VacancyStatus    = VacancyStatuses.Live
            };

            ApprenticeshipVacancyProvider.Setup(p => p.GetVacancyDetailViewModel(It.IsAny <Guid?>(), It.IsAny <int>())).Returns(vacancyDetailViewModel);

            var response = Mediator.Details(Id, null);

            response.AssertMessage(ApprenticeshipSearchMediatorCodes.Details.VacancyHasError, message, UserMessageLevel.Warning, true);
        }
Пример #11
0
        public void ErrorFindingVacancies()
        {
            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Location = ACityWithOneSuggestedLocation
            };

            ApprenticeshipVacancyProvider.Setup(sp => sp.FindVacancies(It.IsAny <ApprenticeshipSearchViewModel>()))
            .Returns(new ApprenticeshipSearchResponseViewModel
            {
                ViewModelMessage = SomeErrorMessage
            });

            var response = Mediator.Results(null, searchViewModel);

            response.AssertMessage(ApprenticeshipSearchMediatorCodes.Results.HasError, SomeErrorMessage,
                                   UserMessageLevel.Warning, true);
        }
Пример #12
0
        public void IfTotalLocalHitsIsGreaterThanZero_LocationTypeIsNonNational()
        {
            var searchViewModel = new ApprenticeshipSearchViewModel
            {
                Location = ACityWithOneSuggestedLocation
            };

            ApprenticeshipVacancyProvider.Setup(sp => sp.FindVacancies(searchViewModel))
            .Returns(new ApprenticeshipSearchResponseViewModel
            {
                TotalLocalHits = 1,
                VacancySearch  = searchViewModel
            });

            var response = Mediator.Results(null, searchViewModel);

            response.AssertCode(ApprenticeshipSearchMediatorCodes.Results.Ok, true);
            response.ViewModel.VacancySearch.LocationType = ApprenticeshipLocationType.NonNational;
        }
        public void VacancyHasError()
        {
            //Arrange
            const string message = "The vacancy has an error";

            var vacancyDetailViewModel = new ApprenticeshipVacancyDetailViewModel
            {
                ViewModelMessage = message
            };

            ApprenticeshipVacancyProvider.Setup(p => p.IncrementClickThroughFor(It.IsAny <int>()))
            .Returns(vacancyDetailViewModel);

            //Act
            var response = Mediator.RedirectToExternalWebsite(Id);

            //Assert
            response.AssertMessage(ApprenticeshipSearchMediatorCodes.RedirectToExternalWebsite.VacancyHasError, message,
                                   UserMessageLevel.Warning, true);
        }
        public ApprenticeshipVacancyProvider Build()
        {
            var provider = new ApprenticeshipVacancyProvider(_vacancySearchService.Object, _candidateService.Object, _mapper, _logger, _candidateVacancyService.Object);

            return(provider);
        }