Пример #1
0
        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);
            }
        }
Пример #3
0
        public void GetFocusKeywordReturnsNullWithNoProperties()
        {
            var mockedIPublishedContent = new PublishedContentMock();

            mockedIPublishedContent.Properties = new List <IPublishedProperty>()
            {
            };

            var focusKeywordHelper = new FocusKeywordHelper();
            var result             = focusKeywordHelper.GetFocusKeyword(mockedIPublishedContent);

            Assert.IsNull(result);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
            }
        }
 public AnalyzeService()
 {
     _focusKeywordHelper   = new FocusKeywordHelper();
     _pageAnalysisService  = new PageAnalysisService();
     _analysisCacheService = new AnalysisCacheRepository();
 }