示例#1
0
        public void Title_BaseTitleEmpty_SetsTitleToPageTitleOnly()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            // Act
            seoHelper.Title = TestData.TestTitle;

            // Assert
            Assert.Equal(TestData.TestTitle, seoHelper.Title);
        }
示例#2
0
        public void Title_Set_TitleEqualsPageTitle()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            // Act
            seoHelper.Title = TestData.TestTitle;

            // Assert
            Assert.Equal(TestData.TestTitle, seoHelper.Title);
        }
示例#3
0
        public void MetaRobotsNoIndex_SetTrue_MetaRobotsIndexEqualsDefaultRobotsNoIndex()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            // Act
            seoHelper.MetaRobotsNoIndex = true;

            // Assert
            Assert.Equal(RobotsIndexManager.DefaultRobotsNoIndex, seoHelper.MetaRobotsIndex);
            Assert.True(seoHelper.MetaRobotsNoIndex);
        }
示例#4
0
        public void MetaRobotsNoIndex_SetFalse_MetaRobotsIndexIsNull()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            // Act
            seoHelper.MetaRobotsNoIndex = false;

            // Assert
            Assert.Null(seoHelper.MetaRobotsIndex);
            Assert.False(seoHelper.MetaRobotsNoIndex);
        }
        public void GetTitle_TitleEmptyAndBaseTitleNotEmpty_ReturnsBaseTitle()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            seoHelper.BaseTitle = TestData.TestBaseTitle;

            // Act
            var title = SeoHelperTitleHelper.GetTitle(seoHelper);

            // Assert
            Assert.Equal(TestData.TestBaseTitle, title);
        }
示例#6
0
        public void OnHandleSeoValues_TestBaseTitle_SetsBaseTitle()
        {
            // Arrange
            var attribute = new SeoBaseTitleAttribute(TestData.TestBaseTitle);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestBaseTitle, seo.BaseTitle);
        }
示例#7
0
        public void OnHandleSeoValues_TestMetaDescription_SetsMetaDescription()
        {
            // Arrange
            var attribute = new SeoMetaDescriptionAttribute(TestData.TestMetaDescription);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestMetaDescription, seo.MetaDescription);
        }
示例#8
0
        public void OnHandleSeoValues_TestLinkCanonical_SetsSeoHelperCanonicalLink()
        {
            // Arrange
            var attribute = new SeoLinkCanonicalAttribute(TestData.TestLinkCanonical);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestLinkCanonical, seo.LinkCanonical);
        }
示例#9
0
        public void OnHandleSeoValues_NoIndexValue_SetsMetaRobotsIndex(RobotsIndex robotsIndex)
        {
            // Arrange
            var attribute = new SeoMetaRobotsIndexAttribute(robotsIndex);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(robotsIndex, seo.MetaRobotsIndex);
        }
        public void OnHandleSeoValues_TestMetaKeywords_SetsMetaKeywords()
        {
            // Arrange
            var attribute = new SeoMetaKeywordsAttribute(TestData.TestMetaKeywords);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestMetaKeywords, seo.MetaKeywords);
        }
示例#11
0
        public void OnHandleSeoValues_Empty_SetsMetaRobotsIndexToNull()
        {
            // Arrange
            var attribute = new SeoMetaRobotsIndexAttribute();

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Null(seo.MetaRobotsIndex);
        }
        public void OnHandleSeoValues_NoIndexValue_MetaNoIndex()
        {
            // Arrange
            var attribute = new SeoMetaRobotsNoIndexAttribute();

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.True(seo.MetaRobotsNoIndex);
            Assert.Equal(RobotsIndexManager.DefaultRobotsNoIndex, seo.MetaRobotsIndex);
        }
示例#13
0
        public void OnHandleSeoValues_TestLinkCanonical_SetsSeoHelperCanonicalLinkOnly()
        {
            // Arrange
            var attribute = new SeoLinkCanonicalAttribute(TestData.TestTitle);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Null(seo.MetaDescription);
            Assert.Null(seo.MetaKeywords);
            Assert.Null(seo.MetaRobotsIndex);
            Assert.Null(seo.Title);
        }
示例#14
0
        public void OnHandleSeoValues_Format_SetsTitleFormat()
        {
            // Arrange
            var attribute = new SeoBaseTitleAttribute(TestData.TestBaseTitle)
            {
                Format = TestData.TestTitleFormat
            };

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestTitleFormat, seo.TitleFormat);
        }
示例#15
0
        public void OnHandleSeoValues_NoIndexValue_MetaNoIndexOnly(RobotsIndex robotsIndex)
        {
            // Arrange
            var attribute = new SeoMetaRobotsIndexAttribute(robotsIndex);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Null(seo.LinkCanonical);
            Assert.Null(seo.MetaDescription);
            Assert.Null(seo.MetaKeywords);
            Assert.Null(seo.Title);
        }
示例#16
0
        public void SeoMetaKeywords_EmptyArgumentWithValueInSeoHelper_ReturnsHtmlContainingValue()
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.MetaKeywords = TestData.TestMetaKeywords;

            // Act
            var html = htmlHelper.SeoMetaKeywords();

            // Assert
            bool htmlContainsValue = html.Contains(TestData.TestMetaKeywords);

            Assert.True(htmlContainsValue);
        }
示例#17
0
        public void OnHandleSeoValues_TestPageTitleAndOverrideBaseTitle_ResetsBaseTitle()
        {
            // Arrange
            var attribute = new SeoTitleAttribute(TestData.TestTitle)
            {
                OverrideBaseTitle = true
            };

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestTitle, seo.Title);
            Assert.Null(seo.BaseTitle);
        }
示例#18
0
        public void SeoTitle_EmptyArgumentWithBaseTitleInSeoHelper_ReturnsHtmlContainingValue()
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.BaseTitle = TestData.TestBaseTitle;

            // Act
            var html = htmlHelper.SeoTitle();

            // Assert
            bool htmlContainsValue = html.Contains(TestData.TestBaseTitle);

            Assert.True(htmlContainsValue);
        }
示例#19
0
        public void SeoLinkCanonical_EmptyArgumentWithValueInSeoHelper_ReturnsHtmlContainingValue()
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.LinkCanonical = $"{TestData.TestLinkCanonical}";

            // Act
            var html = htmlHelper.SeoLinkCanonical();

            // Assert
            bool htmlContainsValue = html.Contains(TestData.TestLinkCanonical);

            Assert.True(htmlContainsValue);
        }
        public void GetTitle_TitleAndBaseTitleNotEmpty_ReturnsTitleWithTitleAndBaseTitle()
        {
            // Arrange
            var seoHelper = SeoHelperTestFactory.Create();

            seoHelper.BaseTitle = TestData.TestBaseTitle;
            seoHelper.Title     = TestData.TestTitle;

            // Act
            var title = SeoHelperTitleHelper.GetTitle(seoHelper);

            // Assert
            bool titleEndsWithSiteTitle   = title.EndsWith(TestData.TestBaseTitle);
            bool titleStartsWithPageTitle = title.StartsWith(TestData.TestTitle);

            Assert.True(titleEndsWithSiteTitle);
            Assert.True(titleStartsWithPageTitle);
        }
示例#21
0
        public void Title_ChangedTitleFormat_SetsTitle()
        {
            const string BaseTitle = "BASE_TITLE";
            const string PageTitle = "PAGE_TITLE";

            // Arrange
            var seo = SeoHelperTestFactory.Create();

            // Act
            seo.BaseTitle   = BaseTitle;
            seo.Title       = PageTitle;
            seo.TitleFormat = TestData.TestTitleFormat;

            // Assert
            string expectedTitle = string.Format(TestData.TestTitleFormat, PageTitle, BaseTitle);

            Assert.Equal(expectedTitle, seo.Title);
        }
示例#22
0
        public void OnHandleSeoValues_TestBaseTitleTwice_SetsBaseTitle()
        {
            const string FirstBaseTitle  = "FIRST_BASE_TITLE";
            const string SecondBaseTitle = "SECOND_BASE_TITLE";

            // Arrange
            var firstAttribute  = new SeoBaseTitleAttribute(FirstBaseTitle);
            var secondAttribute = new SeoBaseTitleAttribute(SecondBaseTitle);

            var seo = SeoHelperTestFactory.Create();

            // Act
            firstAttribute.OnHandleSeoValues(seo);
            secondAttribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(SecondBaseTitle, seo.BaseTitle);
        }
示例#23
0
        public void OnHandleSeoValues_TestBaseTitle_SetsBaseTitleOnly()
        {
            // Arrange
            var attribute = new SeoBaseTitleAttribute(TestData.TestBaseTitle);

            var seo = SeoHelperTestFactory.Create();

            // Act
            attribute.OnHandleSeoValues(seo);

            // Assert
            Assert.Equal(TestData.TestBaseTitle, seo.BaseTitle);
            Assert.Null(seo.LinkCanonical);
            Assert.Null(seo.BaseLinkCanonical);
            Assert.Null(seo.MetaDescription);
            Assert.Null(seo.MetaKeywords);
            Assert.Null(seo.MetaRobotsIndex);
            Assert.Null(seo.Title);
        }
示例#24
0
        public void SeoMetaRobotsIndex_EmptyArgumentWithMetaRobotsNoIndexInSeoHelper_ReturnsHtmlContainingValue()
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.MetaRobotsNoIndex = true;

            // Act
            var html = htmlHelper.SeoMetaRobotsIndex();

            // Assert
            bool htmlContainsRobots      = html.Contains("robots");
            var  defaultRobotsNoIndex    = RobotsIndexManager.GetMetaContent(RobotsIndexManager.DefaultRobotsNoIndex);
            bool htmlContainsMetaContent = html.Contains(defaultRobotsNoIndex);

            Assert.True(htmlContainsRobots);
            Assert.True(htmlContainsMetaContent);
        }
示例#25
0
        SeoLinkCanonical_EmptyArgumentWithAppRelativeValueInSeoHelper_ReturnsHtmlContainingValueAndIsAbsolute()
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.LinkCanonical = TestData.TestAppRelativeLinkCanonical;

            // Act
            var html = htmlHelper.SeoLinkCanonical();

            // Assert
            bool htmlContainsValue  = html.Contains(TestData.TestLinkCanonical);
            bool htmlContainsDomain = html.Contains(RequestContextTestFactory.Domain);
            bool htmlContainsAppRelativeCharacter = html.Contains("~");

            Assert.True(htmlContainsValue);
            Assert.True(htmlContainsDomain);
            Assert.False(htmlContainsAppRelativeCharacter);
        }
示例#26
0
        public void SeoMetaRobotsIndex_EmptyArgumentWithValuesInSeoHelper_ReturnsHtmlContainingValue(
            RobotsIndex robotsIndex,
            string expectedContent)
        {
            // Arrange
            var viewContext = ViewContextTestFactory.Create();
            var htmlHelper  = HtmlHelperTestFactory.Create(viewContext);
            var seoHelper   = SeoHelperTestFactory.Create(viewContext);

            seoHelper.MetaRobotsIndex = robotsIndex;

            // Act
            var html = htmlHelper.SeoMetaRobotsIndex();

            // Assert
            bool htmlContainsRobots          = html.Contains("robots");
            var  metaContent                 = RobotsIndexManager.GetMetaContent(robotsIndex);
            bool htmlContainsMetaContent     = html.Contains(metaContent);
            bool htmlContainsExpectedContent = html.Contains(expectedContent);

            Assert.True(htmlContainsRobots);
            Assert.True(htmlContainsMetaContent);
            Assert.True(htmlContainsExpectedContent);
        }