Exemplo n.º 1
0
        public void RootNodeUrlPrefixSet()
        {
            var parser = new UmbracoXmlParser(_tempFile, new Dictionary <int, string> {
                { 1069, "https://www.example.com" }
            });
            var node = parser.GetNode(1069);

            Assert.AreEqual("https://www.example.com", node.Url);

            // Node 2499 has an umbracoUrlAlias set, which is used along side the root node URL prefix
            node = parser.GetNode(2499);
            Assert.AreEqual("https://www.example.com/news/make-a-wise-decision", node.Url);
        }
Exemplo n.º 2
0
        public void GetPropertyAsDate()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.AreEqual(new DateTime(2015, 5, 22, 12, 10, 22), node.GetPropertyAsDate("dateField"));
        }
Exemplo n.º 3
0
        public void GetPropertyAsInt()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.AreEqual(2048, node.GetPropertyAsInt("intField"));
        }
Exemplo n.º 4
0
        public void GetPropertyAsBool_True()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.IsTrue(node.GetPropertyAsBool("boolFieldTrue"));
        }
Exemplo n.º 5
0
        public void GetPropertyAsString()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.AreEqual("This is a long string with special < > characters.", node.GetPropertyAsString("stringField"));
        }
Exemplo n.º 6
0
        public void GetPropertyAsStringDoesntFindChildNode()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2447);

            Assert.IsNull(node.GetPropertyAsString("Article"));
        }
Exemplo n.º 7
0
        public void GetPropertyAsInt()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1114);

            Assert.AreEqual(2, node.GetPropertyAsInt("howManyPostsShouldBeShown"));
        }
Exemplo n.º 8
0
        public void DeepNodePropertiesSet()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2448);

            Assert.AreEqual(2448, node.Id);
            Assert.AreEqual(2447, node.ParentId);
            Assert.AreEqual("Article", node.Doctype);
            Assert.AreEqual(4, node.Level);
            Assert.AreEqual("People with No or Bad Credit Score", node.Name);
            Assert.AreEqual("example-site/news/oct-2014/people-with-bad-credit-score", node.Url);
            Assert.AreEqual(new DateTime(2015, 5, 13, 12, 10, 33), node.CreateDate);
            Assert.AreEqual(new DateTime(2015, 10, 22, 7, 42, 8), node.UpdateDate);
            Assert.AreEqual("angela", node.CreatorName);
            Assert.AreEqual("admin", node.WriterName);
            Assert.AreEqual(1067, node.TemplateId);
            CollectionAssert.AreEqual(new [] { 1069, 1239, 2447, 2448 }, node.PathIds);
            CollectionAssert.AreEqual(new [] { "Example Site", "News", "Oct 2014", "People with No or Bad Credit Score" }, node.PathNames);

            // Parent
            Assert.AreEqual(2447, node.Parent.Id);
            Assert.AreEqual(1239, node.Parent.ParentId);
            Assert.AreEqual("DateFolder", node.Parent.Doctype);
            Assert.AreEqual(3, node.Parent.Level);
            Assert.AreEqual("Oct 2014", node.Parent.Name);
            Assert.AreEqual("example-site/news/oct-2014", node.Parent.Url);
            Assert.AreEqual(new DateTime(2015, 5, 13, 12, 10, 32), node.Parent.CreateDate);
            Assert.AreEqual(new DateTime(2015, 5, 13, 12, 10, 32), node.Parent.UpdateDate);
            Assert.AreEqual("admin", node.Parent.CreatorName);
            Assert.AreEqual("admin", node.Parent.WriterName);
            Assert.AreEqual(0, node.Parent.TemplateId);
            CollectionAssert.AreEqual(new[] { 1069, 1239, 2447 }, node.Parent.PathIds);
            CollectionAssert.AreEqual(new[] { "Example Site", "News", "Oct 2014" }, node.Parent.PathNames);
        }
Exemplo n.º 9
0
        public void GetPropertyAsString()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1095);

            Assert.AreEqual("Check our products", node.GetPropertyAsString("heroCTACaption"));
        }
Exemplo n.º 10
0
        public void GetPropertyAsBool_True()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1106);

            Assert.IsTrue(node.GetPropertyAsBool("umbracoNavihide"));
        }
Exemplo n.º 11
0
        public void RootNodePropertiesSetWithDoctypeAndUserMappings()
        {
            var parser = new UmbracoXmlParser(_tempFile, new UmbracoParsingOptions
            {
                UrlPrefixMapping = new Dictionary <int, string> {
                    { 1095, "https://www.example.com/" }
                },
                DoctypeMapping = new Dictionary <int, string> {
                    { 1089, "HomeDoctype" }
                },
                UserMapping = new Dictionary <int, string> {
                    { -1, "admin" }
                }
            });
            var node = parser.GetNode(1095);

            Assert.AreEqual(1095, node.Id);
            Assert.AreEqual("ca4249ed2b234337b52263cabe5587d1", node.Uid);
            Assert.IsNull(node.ParentId);
            Assert.AreEqual("HomeDoctype", node.Doctype);
            Assert.AreEqual(1, node.Level);
            Assert.AreEqual("Home", node.Name);
            Assert.AreEqual("https://www.example.com", node.Url);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 16), node.CreateDate);
            Assert.AreEqual(new DateTime(2019, 6, 25, 14, 5, 34), node.UpdateDate);
            Assert.AreEqual("admin", node.CreatorName);
            Assert.AreEqual("admin", node.WriterName);
            Assert.AreEqual(1076, node.TemplateId);
            CollectionAssert.AreEqual(new[] { 1095 }, node.PathIds);
            CollectionAssert.AreEqual(new[] { "Home" }, node.PathNames);

            // Parent
            Assert.IsNull(node.Parent);
        }
Exemplo n.º 12
0
        public void GetPropertyAsDate()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1117);

            Assert.AreEqual(new DateTime(2019, 10, 19, 13, 15, 0), node.GetPropertyAsDate("publishedDate"));
        }
Exemplo n.º 13
0
        public void DeepNodeUrlPrefixSetWithTrailingSlash()
        {
            var parser = new UmbracoXmlParser(_tempFile, new Dictionary <int, string> {
                { 1095, "https://www.example.com/" }
            });
            var node = parser.GetNode(1097);

            Assert.AreEqual("https://www.example.com/products/tattoo", node.Url);
        }
Exemplo n.º 14
0
        public void RootNodeUrlPrefixSet()
        {
            var parser = new UmbracoXmlParser(_tempFile, new Dictionary <int, string> {
                { 1095, "https://www.example.com" }
            });
            var node = parser.GetNode(1095);

            Assert.AreEqual("https://www.example.com", node.Url);
        }
Exemplo n.º 15
0
        public void DeepNodeUrlPrefixSetWithTrailingSlash()
        {
            var parser = new UmbracoXmlParser(_tempFile, new Dictionary <int, string> {
                { 1069, "https://www.example.com/" }
            });
            var node = parser.GetNode(2448);

            Assert.AreEqual("https://www.example.com/news/oct-2014/people-with-bad-credit-score", node.Url);
        }
Exemplo n.º 16
0
        public void GetPropertiesIgnoresChildNodes()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var node       = parser.GetNode(2447);
            var dictionary = node.GetProperties();

            Assert.AreEqual(2, dictionary.Keys.Count);
            Assert.AreEqual("2015-05-13T12:10:32", dictionary["dateField"]);
            Assert.AreEqual("1", dictionary["boolField"]);
        }
Exemplo n.º 17
0
        public void GetChildren()
        {
            var parser   = new UmbracoXmlParser(_tempFile);
            var node     = parser.GetNode(2447);
            var children = node.Children;

            Assert.AreEqual(2, children.Count());
            Assert.AreEqual(2448, children.ElementAt(0).Id);
            Assert.AreEqual(2499, children.ElementAt(1).Id);
        }
Exemplo n.º 18
0
        public void GetPropertyAsXmlString()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.AreEqual(@"<nodes>
  <node>1</node>
  <node>2</node>
  <node>3</node>
</nodes>", node.GetPropertyAsXmlString("xmlField"));
        }
Exemplo n.º 19
0
        public void GetChildren()
        {
            var parser   = new UmbracoXmlParser(_tempFile);
            var node     = parser.GetNode(1105);
            var children = node.Children;

            Assert.AreEqual(5, children.Count());
            Assert.AreEqual(1106, children.ElementAt(0).Id);
            Assert.AreEqual(1107, children.ElementAt(1).Id);
            Assert.AreEqual(1108, children.ElementAt(2).Id);
            Assert.AreEqual(1109, children.ElementAt(3).Id);
            Assert.AreEqual(1110, children.ElementAt(4).Id);
        }
Exemplo n.º 20
0
        public void GetProperties()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var node       = parser.GetNode(2552);
            var dictionary = node.GetProperties();

            Assert.AreEqual(9, dictionary.Keys.Count);
            Assert.AreEqual("2015-05-22T12:10:22", dictionary["dateField"]);
            Assert.AreEqual("0", dictionary["boolFieldFalse"]);
            Assert.AreEqual("1", dictionary["boolFieldTrue"]);
            Assert.AreEqual("2048", dictionary["intField"]);
            Assert.AreEqual("<nodes><node>1</node><node>2</node><node>3</node></nodes>", dictionary["xmlField"]);
            Assert.AreEqual("This is a long string with special < > characters.", dictionary["stringField"]);
        }
Exemplo n.º 21
0
        public void GetNodeByGuid()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode("ec4aafcc0c254f25a8fe705bfae1d324");

            Assert.AreEqual(1096, node.Id);
            Assert.AreEqual("ec4aafcc0c254f25a8fe705bfae1d324", node.Uid);
            Assert.AreEqual(1095, node.ParentId);
            Assert.AreEqual("1085", node.Doctype);
            Assert.AreEqual(2, node.Level);
            Assert.AreEqual("Products", node.Name);
            Assert.AreEqual("home/products", node.Url);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 16), node.CreateDate);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 17), node.UpdateDate);
            Assert.AreEqual("-1", node.CreatorName);
            Assert.AreEqual("-1", node.WriterName);
            Assert.AreEqual(1081, node.TemplateId);
            CollectionAssert.AreEqual(new[] { 1095, 1096 }, node.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products" }, node.PathNames);

            // Confirm in actual GUID format
            node = parser.GetNode("EC4AAFCC-0C25-4F25-A8FE-705BFAE1D324");
            Assert.AreEqual(1096, node.Id);
        }
Exemplo n.º 22
0
        public void TestEscapingAndCdata()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var node       = parser.GetNode(2552);
            var dictionary = node.GetProperties();

            // <escapedString>Jack &amp; Jill</escapedString>
            // <cdataString><![CDATA[Jack & Jill]]></cdataString>
            // <cdataEscapedString><![CDATA[Jack &amp; Jill]]></cdataEscapedString>
            Assert.AreEqual("Jack & Jill", dictionary["escapedString"]);
            Assert.AreEqual("Jack & Jill", node.GetPropertyAsString("escapedString"));
            Assert.AreEqual("Jack & Jill", dictionary["cdataString"]);
            Assert.AreEqual("Jack & Jill", node.GetPropertyAsString("cdataString"));
            Assert.AreEqual("Jack &amp; Jill", dictionary["cdataEscapedString"]);
            Assert.AreEqual("Jack &amp; Jill", node.GetPropertyAsString("cdataEscapedString"));
        }
Exemplo n.º 23
0
        public void RootNodePropertiesSet()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1069);

            Assert.AreEqual(1069, node.Id);
            Assert.IsNull(node.ParentId);
            Assert.AreEqual("SiteRoot", node.Doctype);
            Assert.AreEqual(1, node.Level);
            Assert.AreEqual("Example Site", node.Name);
            Assert.AreEqual("example-site", node.Url);
            Assert.AreEqual(new DateTime(2014, 12, 12, 13, 23, 29), node.CreateDate);
            Assert.AreEqual(new DateTime(2016, 9, 1, 16, 45, 19), node.UpdateDate);
            Assert.AreEqual("admin", node.CreatorName);
            Assert.AreEqual("james", node.WriterName);
            Assert.AreEqual(1067, node.TemplateId);
            CollectionAssert.AreEqual(new[] { 1069 }, node.PathIds);
            CollectionAssert.AreEqual(new[] { "Example Site" }, node.PathNames);

            // Parent
            Assert.IsNull(node.Parent);
        }
Exemplo n.º 24
0
        public void GetTypedProperties()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var node       = parser.GetNode(1114);
            var dictionary = node.GetTypedProperties();

            Assert.AreEqual(5, dictionary.Keys.Count);
            foreach (var key in dictionary.Keys)
            {
                Console.WriteLine("{0} ({1}) = {2}", key, dictionary[key].GetType().Name, dictionary[key]);
            }
            Assert.AreEqual("Behind The Scenes", dictionary["pageTitle"]);
            Assert.AreEqual("{\n  \"name\": \"1 column layout\",\n  \"sections\": [\n    {\n      \"grid\": 12,\n      \"allowAll\": true,\n      \"rows\": []\n    }\n  ]\n}", dictionary["bodyText"]);
            Assert.AreEqual("[]", dictionary["keywords"]);
            Assert.AreEqual(0, dictionary["umbracoNavihide"]);
            Assert.AreEqual("2", dictionary["howManyPostsShouldBeShown"]);

            Assert.IsTrue(dictionary["pageTitle"] is String);
            Assert.IsTrue(dictionary["bodyText"] is String);
            Assert.IsTrue(dictionary["keywords"] is String);
            Assert.IsTrue(dictionary["umbracoNavihide"] is Int32);
            Assert.IsTrue(dictionary["howManyPostsShouldBeShown"] is String);
        }
Exemplo n.º 25
0
        public void GetProperties()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var node       = parser.GetNode(1095);
            var dictionary = node.GetProperties();

            Assert.AreEqual(15, dictionary.Keys.Count);
            Assert.AreEqual("Umbraco Demo", dictionary["heroHeader"]);
            Assert.AreEqual("Moonfish, steelhead, lamprey southern flounder tadpole fish sculpin bigeye, blue-redstripe danio collared dogfish. Smalleye squaretail goldfish arowana butterflyfish pipefish wolf-herring jewel tetra, shiner; gibberfish red velvetfish. Thornyhead yellowfin pike threadsail ayu cutlassfish.", dictionary["heroDescription"]);
            Assert.AreEqual("Check our products", dictionary["heroCTACaption"]);
            Assert.AreEqual("umb://document/ec4aafcc0c254f25a8fe705bfae1d324", dictionary["HeroCtalink"]);
            Assert.AreEqual("{\r\n  \"make\": \"Holden\",\r\n  \"model\": \"Commodore\"\r\n}", dictionary["g5amx923cj7"]);
            Assert.IsTrue(dictionary["bodyText"].StartsWith("{") && dictionary["bodyText"].EndsWith("}"));
            Assert.AreEqual("Umbraco Demo", dictionary["footerHeader"]);
            Assert.AreEqual("Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vivamus suscipit tortor eget felis porttitor volutpat", dictionary["footerDescription"]);
            Assert.AreEqual("Read All on the Blog", dictionary["footerCTACaption"]);
            Assert.AreEqual("umb://document/1d770f10d1ca4a269d68071e2c9f7ac1", dictionary["FooterCtalink"]);
            Assert.AreEqual("Umbraco HQ - Unicorn Square - Haubergsvej 1 - 5000 Odense C - Denmark - +45 70 26 11 62", dictionary["footerAddress"]);
            Assert.AreEqual("umb://media/662af6ca411a4c93a6c722c4845698e7", dictionary["HeroBackgroundImage"]);
            Assert.AreEqual("serif", dictionary["font"]);
            Assert.AreEqual("earth", dictionary["colorTheme"]);
            Assert.AreEqual("Umbraco Sample Site", dictionary["sitename"]);
        }
Exemplo n.º 26
0
        public void RootNodePropertiesSet()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1095);

            Assert.AreEqual(1095, node.Id);
            Assert.AreEqual("ca4249ed2b234337b52263cabe5587d1", node.Uid);
            Assert.IsNull(node.ParentId);
            Assert.AreEqual("1089", node.Doctype);
            Assert.AreEqual(1, node.Level);
            Assert.AreEqual("Home", node.Name);
            Assert.AreEqual("home", node.Url);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 16), node.CreateDate);
            Assert.AreEqual(new DateTime(2019, 6, 25, 14, 5, 34), node.UpdateDate);
            Assert.AreEqual("-1", node.CreatorName);
            Assert.AreEqual("-1", node.WriterName);
            Assert.AreEqual(1076, node.TemplateId);
            CollectionAssert.AreEqual(new[] { 1095 }, node.PathIds);
            CollectionAssert.AreEqual(new[] { "Home" }, node.PathNames);

            // Parent
            Assert.IsNull(node.Parent);
        }
Exemplo n.º 27
0
        public void DeepNodePropertiesSet()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1097);

            Assert.AreEqual(1097, node.Id);
            Assert.AreEqual("df1eb830411b4d41a3433917b76d533c", node.Uid);
            Assert.AreEqual(1096, node.ParentId);
            Assert.AreEqual("1086", node.Doctype);
            Assert.AreEqual(3, node.Level);
            Assert.AreEqual("Tattoo", node.Name);
            Assert.AreEqual("home/products/tattoo", node.Url);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 16), node.CreateDate);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 17), node.UpdateDate);
            Assert.AreEqual("-1", node.CreatorName);
            Assert.AreEqual("-1", node.WriterName);
            Assert.AreEqual(1080, node.TemplateId);
            CollectionAssert.AreEqual(new [] { 1095, 1096, 1097 }, node.PathIds);
            CollectionAssert.AreEqual(new [] { "Home", "Products", "Tattoo" }, node.PathNames);

            // Parent
            Assert.AreEqual(1096, node.Parent.Id);
            Assert.AreEqual("ec4aafcc0c254f25a8fe705bfae1d324", node.Parent.Uid);
            Assert.AreEqual(1095, node.Parent.ParentId);
            Assert.AreEqual("1085", node.Parent.Doctype);
            Assert.AreEqual(2, node.Parent.Level);
            Assert.AreEqual("Products", node.Parent.Name);
            Assert.AreEqual("home/products", node.Parent.Url);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 16), node.Parent.CreateDate);
            Assert.AreEqual(new DateTime(2019, 6, 25, 8, 4, 17), node.Parent.UpdateDate);
            Assert.AreEqual("-1", node.Parent.CreatorName);
            Assert.AreEqual("-1", node.Parent.WriterName);
            Assert.AreEqual(1081, node.Parent.TemplateId);
            CollectionAssert.AreEqual(new[] { 1095, 1096 }, node.Parent.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products" }, node.Parent.PathNames);
        }