public void Title_BaseTitleEmpty_SetsTitleToPageTitleOnly() { // Arrange var seoHelper = SeoHelperTestFactory.Create(); // Act seoHelper.Title = TestData.TestTitle; // Assert Assert.Equal(TestData.TestTitle, seoHelper.Title); }
public void Title_Set_TitleEqualsPageTitle() { // Arrange var seoHelper = SeoHelperTestFactory.Create(); // Act seoHelper.Title = TestData.TestTitle; // Assert Assert.Equal(TestData.TestTitle, seoHelper.Title); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }