public void ShouldShowPercentageForAchievementRateResultWhenprovided()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "100PercentEmployer"
                },
                Address = new Address(),
                EmployerSatisfactionMessage = "87%",
                LearnerSatisfactionMessage  = "99.9%",
                AchievementRateMessage      = "42.5%",
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };

            var model = new ProviderStandardSearchResultViewModel()
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result-data-list dt", 4).Should().Be("Achievement rate:");
            GetPartial(html, ".result-data-list dd", 4).Should().Be("42.5%");
        }
        public void ShouldIncludeNationalTagIfItsANationalProvider()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName     = "Provider 1",
                NationalProvider = true,
                DeliveryModes    = new List <string> {
                    "100PercentEmployer"
                },
                Address = new Address(),
                EmployerSatisfactionMessage = "87%",
                LearnerSatisfactionMessage  = "99.9%",
                AchievementRateMessage      = "42.5%",
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };

            var model = new ProviderStandardSearchResultViewModel()
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result-title").Should().EndWith("National");
        }
        public void ShouldShowJustDistanceIfDeliveryModeIsNotEmployerLocation()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "BlockRelease"
                },
                Distance     = 1.2,
                Address      = new Address(),
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };

            var model = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result dl dt").Should().Be("Distance:");
            GetPartial(html, ".result dl dd").Should().Be("1.2 miles away");
        }
        public void ShouldShowDeliveryModesWithCorrectOrder()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "BlockRelease", "100PercentEmployer", "DayRelease"
                },
                Distance               = 1.2,
                Address                = new Address(),
                UkPrn                  = 1,
                LocationId             = 2,
                StandardCode           = 12,
                DeliveryOptionsMessage = "day release, block release, at your location"
            };

            var model = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".deliveryOptions").Should().Be("day release, block release, at your location");
        }
        public void ShouldHaveAllFieldsInSearchResult()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "100PercentEmployer"
                },
                Distance     = 1,
                Address      = new Address(),
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };
            var item2 = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 2",
                DeliveryModes = new List <string> {
                    "BlockRelease"
                },
                Distance     = 1.2,
                Address      = new Address(),
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };

            var model = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item, item2
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result dl dt").Should().Be("Distance:");

            GetPartial(html, ".result dl dd").Should().Be("1 mile away");

            var secondResult = GetHtmlElement(html, ".result", 2);

            GetPartial(secondResult, "dl dd").Should().Be("1.2 miles away");
        }
        public void ShouldAddIntervalToResultsForGoogleAnalytics(int resultIndex, string expectedText, int acctualPage)
        {
            var searchPage = new StandardProviderInformation();

            var results = from ll in new StandardProviderResultItemViewModel[10] select new StandardProviderResultItemViewModel {
                ProviderName = "Test"
            };

            var model = new ProviderStandardSearchResultViewModel {
                TotalResults = 10, Hits = results, ActualPage = acctualPage, ResultsToTake = 10,
            };
            var html = searchPage.RenderAsHtml(model).ToAngleSharp();

            GetAttribute(html, "article a", "attr-ga-result-interval", resultIndex).Should().BeEquivalentTo(expectedText);
        }
        public void ShouldShowProviderLocationIfDeliveryModeDoesNotContainHundredEmployerLocation()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "BlockRelease"
                },
                Distance = 3,
                Address  = new Address
                {
                    Address1 = "Address 1",
                    Address2 = "Address 2",
                    County   = "County",
                    Postcode = "PostCode",
                    Town     = "Town"
                },
                LocationAddressLine = "Address 1, Address 2, Town, County, PostCode",
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12
            };

            var model = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result dl dt").Should().Be("Distance:");

            GetPartial(html, ".result dl dd").Should().Be("3 miles away");

            GetPartial(html, ".address").Should().Be("Address 1, Address 2, Town, County, PostCode");
        }
        public void ShouldntShowTrainingLocationIfDeliveryModeContainsEmployerLocationAndItIsTheOnlyOne()
        {
            var page = new StandardProviderInformation();
            var item = new StandardProviderResultItemViewModel
            {
                ProviderName  = "Provider 1",
                DeliveryModes = new List <string> {
                    "100PercentEmployer"
                },
                Address = new Address
                {
                    Address1 = "Address 1",
                    Address2 = "Address 2",
                    County   = "County",
                    Postcode = "PostCode",
                    Town     = "Town"
                },
                UkPrn        = 1,
                LocationId   = 2,
                StandardCode = 12,
                Distance     = 0
            };

            var model = new ProviderStandardSearchResultViewModel
            {
                TotalResults    = 1,
                PostCodeMissing = false,
                StandardId      = "1",
                StandardName    = "Test name",
                Hits            = new List <StandardProviderResultItemViewModel> {
                    item
                },
                HasError = false
            };
            var html = page.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".result dl dt").Should().Be("Distance:");

            GetPartial(html, ".result dl dd").Should().Be("0 miles away");

            GetPartial(html, ".address").Should().Be(string.Empty);
        }