Exemplo n.º 1
0
        public void DFC1940ScenarioA1ForShowPsfResults(int count, int totalPages, int currentPage)
        {
            var resultsView = new _MVC_Views_PsfSearch_SearchResult_cshtml();

            var psfSearchResultsViewModel = GenerateDummyJobProfileSearchResultViewModel(count, totalPages, DummyMultipleJobProfileSearchResults(count), $"{count} result found", count, currentPage);

            var htmlDom = resultsView.RenderAsHtml(psfSearchResultsViewModel);

            var mainPageTitle = GetFirstTagText(htmlDom, "h1");
            var secondaryText = GetFirstTagTextWithClass(htmlDom, "p", "filter-results-subheading");
            var backText      = GetFirstTagText(htmlDom, "button");
            var backUrl       = GetPreviouspageUrl(htmlDom);
            var searchResults = GetSearchResults(htmlDom);

            mainPageTitle.Should().BeEquivalentTo(psfSearchResultsViewModel.MainPageTitle + psfSearchResultsViewModel.SecondaryText);
            searchResults.Should().BeEquivalentTo(psfSearchResultsViewModel.SearchResults);
            backText.Should().BeEquivalentTo(psfSearchResultsViewModel.BackPageUrlText);
            backUrl.Should().BeEquivalentTo(psfSearchResultsViewModel.BackPageUrl.OriginalString);

            if (psfSearchResultsViewModel.HasNextPage)
            {
                GetPaginationNextVisible(htmlDom).Should().BeTrue();
                GetNavigationUrl(htmlDom, true, "dfc-code-search-next next").Should().BeEquivalentTo(psfSearchResultsViewModel.NextPageUrlText);
                GetNavigationUrl(htmlDom, false, "dfc-code-search-next next").Should().BeEquivalentTo(psfSearchResultsViewModel.NextPageUrl.OriginalString);
            }

            if (psfSearchResultsViewModel.HasPreviousPage)
            {
                GetPaginationPreviousVisible(htmlDom).Should().BeTrue();
                GetNavigationUrl(htmlDom, true, "dfc-code-search-previous previous").Should().BeEquivalentTo(psfSearchResultsViewModel.PreviousPageUrlText);
                GetNavigationUrl(htmlDom, false, "dfc-code-search-previous previous").Should().BeEquivalentTo(psfSearchResultsViewModel.PreviousPageUrl.OriginalString);
            }
        }
Exemplo n.º 2
0
        public void MatchingSkillsIsDisplayed(int?numberMatchingProfiles, bool matchingMessageIsDisplayed)
        {
            //Assign
            var searchResultsView = new _MVC_Views_PsfSearch_SearchResult_cshtml();
            var dummyJobProfiles  = new List <JobProfileSearchResultItemViewModel>()
            {
                new JobProfileSearchResultItemViewModel()
                {
                    MatchingSkillsCount = numberMatchingProfiles
                }
            };

            var psfSearchResultsViewModel = GenerateDummyJobProfileSearchResultViewModel(1, 1, dummyJobProfiles, "10 results found", 10, 1);

            psfSearchResultsViewModel.SearchResults.FirstOrDefault().MatchingSkillsCount = numberMatchingProfiles;

            //Act
            var htmlDom = searchResultsView.RenderAsHtml(psfSearchResultsViewModel);

            //Assert
            var matchingMessageNode = htmlDom?.DocumentNode?.SelectNodes($"//*[@id='results']/div/div/ol/li/p[3]")?.FirstOrDefault();

            if (matchingMessageIsDisplayed)
            {
                matchingMessageNode.Should().NotBeNull();
                matchingMessageNode.InnerText.Should().Contain($"Matching Skills: {numberMatchingProfiles}");
            }
            else
            {
                matchingMessageNode.Should().BeNull();
            }
        }
Exemplo n.º 3
0
        public void DFC1510ForSalaryVariableText(string salaryText, string salaryRange, string expectedValue)
        {
            //Assign
            var searchResultsView         = new _MVC_Views_PsfSearch_SearchResult_cshtml();
            var psfSearchResultsViewModel = GenerateDummyJobProfileSearchResultViewModel(1, 1, DummyMultipleJobProfileSearchResults(1, 0, salaryRange), "1 result found", 1, 1);

            psfSearchResultsViewModel.SalaryBlankText = salaryText;

            //Act
            var htmlDom = searchResultsView.RenderAsHtml(psfSearchResultsViewModel);

            //Assert
            GetSalaryText(htmlDom).Should().BeEquivalentTo(expectedValue);
        }
Exemplo n.º 4
0
        public void DFC13339TotalResultCountDataAttribForGoogleAnalytics(long?totalResultCount, string result)
        {
            //Assign
            var searchResultsView         = new _MVC_Views_PsfSearch_SearchResult_cshtml();
            var psfSearchResultsViewModel = GenerateDummyJobProfileSearchResultViewModel(1, 1, DummyMultipleJobProfileSearchResults(1), $"{totalResultCount} result found", totalResultCount, 1);

            //Act
            var htmlDom = searchResultsView.RenderAsHtml(psfSearchResultsViewModel);

            //Assert
            var filter_results_count = htmlDom.DocumentNode.Descendants("div").FirstOrDefault(div => div.Attributes["class"].Value.Contains("filter-results-count"));

            filter_results_count.Attributes.Any(a => a.Name.Equals("data-ga-result-count", StringComparison.OrdinalIgnoreCase)).Should().BeTrue();
            filter_results_count.Attributes.FirstOrDefault(a => a.Name.Equals("data-ga-result-count", StringComparison.OrdinalIgnoreCase)).Value.Should().Be(result);
        }
Exemplo n.º 5
0
        public void DFC1495ForPSFResultsAlsoFoundInCategories(int numberOfLinkedJobCategories)
        {
            var searchResultsView = new _MVC_Views_PsfSearch_SearchResult_cshtml();

            var psfSearchResultsViewModel = GenerateDummyJobProfileSearchResultViewModel(1, 1, DummyMultipleJobProfileSearchResults(10, numberOfLinkedJobCategories), "10 results found", 10, 1);

            var htmlDom = searchResultsView.RenderAsHtml(psfSearchResultsViewModel);

            var linkedCategorySection = htmlDom.DocumentNode.SelectSingleNode("//p[contains(@class, 'results-categories')]");

            if (numberOfLinkedJobCategories <= 0)
            {
                //The section should not be displayed if no linked categories
                linkedCategorySection.Should().BeNull();
            }
            else
            {
                //Should have found in section
                linkedCategorySection.InnerText.Should().Contain("Found in:");
                var foundInCategoryLinks  = GetDisplayedViewAnchorLinks(linkedCategorySection);
                var expectedCategoryLinks = GetLinkedCategories(numberOfLinkedJobCategories, "/job-categories/");
                foundInCategoryLinks.Should().BeEquivalentTo(expectedCategoryLinks);
            }
        }