コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public void GetNodeHtmlFromPublishedContentWithIdReturnsNull()
        {
            IPublishedContent publishedContent = new StubPublishedContentBase
            {
                TemplateIdGet = () => 1,
                IdGet         = () => 0
            };

            var contentHelper = new TemplateHelper(_umbracoHelper);

            contentHelper.GetNodeHtml(publishedContent);
        }
コード例 #3
0
        public void GetNodeHtmlFromPublishedContentWithIdReturnsObject()
        {
            IPublishedContent publishedContent = new StubPublishedContentBase
            {
                TemplateIdGet = () => 1,
                IdGet         = () => 1
            };

            var contentHelper = new TemplateHelper(_umbracoHelper);

            var result = contentHelper.GetNodeHtml(publishedContent);

            Assert.IsInstanceOfType(result, typeof(string));
            Assert.AreEqual("<html>test</html>", result);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
            }
        }