public void GetFocusKeyword_OnExectureWithNullParameter_ThrowsException() { var dashboardSettingsSerializerMock = new Mock <IDashboardSettingsSerializer>(); var focusKeywordHelper = new FocusKeywordHelper(dashboardSettingsSerializerMock.Object); focusKeywordHelper.GetFocusKeyword(null); }
public void GetFocusKeywordReturnsFocusKeywordFromDashboardProperty() { using (ShimsContext.Create()) { var propertyMock = new Mock <IPublishedProperty>(); propertyMock.SetupGet(x => x.HasValue).Returns(true); propertyMock.SetupGet(x => x.Value).Returns("{\"focusKeyword\": \"umbraco\"}"); IPublishedContent publishedContent = new StubPublishedContentBase { PropertiesGet = () => new List <IPublishedProperty> { propertyMock.Object } }; Umbraco.Web.Fakes.ShimPublishedContentExtensions.HasPropertyIPublishedContentString = (node, alias) => { return(false); }; var focusKeywordHelper = new FocusKeywordHelper(); var result = focusKeywordHelper.GetFocusKeyword(publishedContent); Assert.AreEqual("umbraco", result); } }
public void GetFocusKeywordReturnsNullWithNoProperties() { var mockedIPublishedContent = new PublishedContentMock(); mockedIPublishedContent.Properties = new List <IPublishedProperty>() { }; var focusKeywordHelper = new FocusKeywordHelper(); var result = focusKeywordHelper.GetFocusKeyword(mockedIPublishedContent); Assert.IsNull(result); }
public void GetFocusKeywordReturnsFocusKeywordProperty() { var mockedIPublishedContent = new PublishedContentMock(); mockedIPublishedContent.Properties = new List <IPublishedProperty>() { new PublishedPropertyMock() { PropertyTypeAlias = "focusKeyword", Value = "test keyword" } }; var dashboardSettingsSerializerMock = new Mock <IDashboardSettingsSerializer>(); var focusKeywordHelper = new FocusKeywordHelper(dashboardSettingsSerializerMock.Object); var result = focusKeywordHelper.GetFocusKeyword(mockedIPublishedContent); Assert.AreEqual("test keyword", result); }
public PageAnalysis CreateAnalysis(IPublishedContent node, string focusKeyword = null) { if (node.TemplateId == 0) { throw new MissingFieldException("TemplateId is not set"); } if (!string.IsNullOrEmpty(focusKeyword)) { focusKeyword = _focusKeywordHelper.GetFocusKeyword(node); } var analysis = _pageAnalysisService.CreatePageAnalysis(node, focusKeyword); CreateCachedAnalysisItem(node.Id, analysis); return(analysis); }
public void GetFocusKeywordReturnsNullFromEmptyDashboardProperty() { var mockedIPublishedContent = new PublishedContentMock(); mockedIPublishedContent.Properties = new List <IPublishedProperty>() { new PublishedPropertyMock() { PropertyTypeAlias = "otherProperty", Value = "{\"focusKeyword\": \"\"}" } }; var dashboardSettingsSerializerMock = new Mock <IDashboardSettingsSerializer>(); var focusKeywordHelper = new FocusKeywordHelper(); var result = focusKeywordHelper.GetFocusKeyword(mockedIPublishedContent); Assert.IsNull(result); }
public void GetFocusKeywordReturnsNullWithNoProperties() { using (ShimsContext.Create()) { IPublishedContent publishedContent = new StubPublishedContentBase { PropertiesGet = () => new List <IPublishedProperty>() }; Umbraco.Web.Fakes.ShimPublishedContentExtensions.HasPropertyIPublishedContentString = (node, alias) => { return(false); }; var focusKeywordHelper = new FocusKeywordHelper(); var result = focusKeywordHelper.GetFocusKeyword(publishedContent); Assert.IsNull(result); } }
public void GetFocusKeywordReturnsFocusKeywordProperty() { using (ShimsContext.Create()) { IPublishedContent publishedContent = new StubPublishedContentBase(); // Fake HasProperty extension method Umbraco.Web.Fakes.ShimPublishedContentExtensions.HasPropertyIPublishedContentString = (node, alias) => { switch (alias) { case "focusKeyword": return(true); default: return(false); } }; // Fake GetPropertyValue<string> extension method Umbraco.Web.Fakes.ShimPublishedContentExtensions.GetPropertyValueOf1IPublishedContentString( (node, alias) => { switch (alias) { case "focusKeyword": return("test keyword"); default: return(null); } }); var focusKeywordHelper = new FocusKeywordHelper(); var result = focusKeywordHelper.GetFocusKeyword(publishedContent); Assert.AreEqual("test keyword", result); } }