コード例 #1
0
        public void GetPropertyAsInt()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1114);

            Assert.AreEqual(2, node.GetPropertyAsInt("howManyPostsShouldBeShown"));
        }
コード例 #2
0
        public void GetPropertyAsBool_True()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1106);

            Assert.IsTrue(node.GetPropertyAsBool("umbracoNavihide"));
        }
コード例 #3
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);
        }
コード例 #4
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"));
        }
コード例 #5
0
        public void GetPropertyAsStringDoesntFindChildNode()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2447);

            Assert.IsNull(node.GetPropertyAsString("Article"));
        }
コード例 #6
0
        /// <summary>
        /// Construct from an Umbraco 8 ContentNodeKit.
        /// </summary>
        internal UmbracoNode(UmbracoXmlParser parser, int id, ContentNodeKit treeNode, string url, List <int> pathIds, List <string> pathNames)
        {
            _parser = parser;
            if (treeNode.PublishedData != null)
            {
                _propertyData = treeNode.PublishedData.Properties;
            }

            Id  = id;
            Uid = treeNode.Node.Uid.ToString().Replace("-", string.Empty).ToLower();

            ParentId = pathIds.Skip(pathIds.Count - 2).FirstOrDefault();
            if (ParentId == -1)
            {
                ParentId = null;
            }

            Name        = pathNames.Last();
            Url         = url;
            PathIds     = pathIds.Skip(1).ToList(); // skip -1 root
            PathNames   = pathNames;
            Doctype     = _parser.Options.DoctypeMapping != null && _parser.Options.DoctypeMapping.ContainsKey(treeNode.ContentTypeId) ? _parser.Options.DoctypeMapping[treeNode.ContentTypeId] : treeNode.ContentTypeId.ToString();
            Level       = pathIds.Count - 1;
            CreateDate  = new DateTime(treeNode.Node.CreateDate.Ticks - (treeNode.Node.CreateDate.Ticks % TimeSpan.TicksPerSecond), treeNode.Node.CreateDate.Kind);
            UpdateDate  = treeNode.PublishedData != null ? new DateTime(treeNode.PublishedData.VersionDate.Ticks - (treeNode.PublishedData.VersionDate.Ticks % TimeSpan.TicksPerSecond), treeNode.PublishedData.VersionDate.Kind) : CreateDate;
            CreatorName = _parser.Options.UserMapping != null && _parser.Options.UserMapping.ContainsKey(treeNode.Node.CreatorId) ? _parser.Options.UserMapping[treeNode.Node.CreatorId] : treeNode.Node.CreatorId.ToString();
            WriterName  = _parser.Options.UserMapping != null && treeNode.PublishedData != null && _parser.Options.UserMapping.ContainsKey(treeNode.PublishedData.WriterId) ? _parser.Options.UserMapping[treeNode.PublishedData.WriterId] : treeNode.PublishedData != null?treeNode.PublishedData.WriterId.ToString() : null;

            TemplateId = treeNode.PublishedData != null && treeNode.PublishedData.TemplateId.HasValue ? treeNode.PublishedData.TemplateId.Value : default(int);
        }
コード例 #7
0
        public void GetPropertyAsInt()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.AreEqual(2048, node.GetPropertyAsInt("intField"));
        }
コード例 #8
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"));
        }
コード例 #9
0
        public void GetPropertyAsBool_True()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(2552);

            Assert.IsTrue(node.GetPropertyAsBool("boolFieldTrue"));
        }
コード例 #10
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"));
        }
コード例 #11
0
        public void GetPropertyAsString()
        {
            var parser = new UmbracoXmlParser(_tempFile);
            var node   = parser.GetNode(1095);

            Assert.AreEqual("Check our products", node.GetPropertyAsString("heroCTACaption"));
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #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);
        }
コード例 #15
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);
        }
コード例 #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"]);
        }
コード例 #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);
        }
コード例 #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"));
        }
コード例 #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);
        }
コード例 #20
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);
        }
コード例 #21
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"]);
        }
コード例 #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"));
        }
コード例 #23
0
        /// <summary>
        /// Construct from an Umbraco 4 through 7 XML element.
        /// </summary>
        internal UmbracoNode(UmbracoXmlParser parser, int id, XElement element, string url, List <int> pathIds, List <string> pathNames)
        {
            _element = element;
            _parser  = parser;

            Id = id;

            ParentId = pathIds.Skip(pathIds.Count - 2).FirstOrDefault();
            if (ParentId == -1)
            {
                ParentId = null;
            }

            Name      = pathNames.Last();
            Url       = url;
            PathIds   = pathIds.Skip(1).ToList(); // skip -1 root
            PathNames = pathNames;
            Doctype   = element.Name.LocalName;
            Level     = pathIds.Count - 1;
            try
            {
                CreateDate = DateTime.ParseExact(element.Attribute("createDate").Value, "yyyy-MM-ddTHH:mm:ss", CultureInfo.GetCultureInfo("en-us"));
            }
            catch (Exception e)
            {
                throw new UmbracoXmlParsingException(string.Format("Unparsable createDate attribute '{0}' on node ID {1}", element.Attribute("createDate").Value, Id), e);
            }
            try
            {
                UpdateDate = DateTime.ParseExact(element.Attribute("updateDate").Value, "yyyy-MM-ddTHH:mm:ss", CultureInfo.GetCultureInfo("en-us"));
            }
            catch (Exception e)
            {
                throw new UmbracoXmlParsingException(string.Format("Unparsable updateDate attribute '{0}' on node ID {1}", element.Attribute("updateDate").Value, Id), e);
            }
            CreatorName = element.Attribute("creatorName").Value;
            WriterName  = element.Attribute("writerName").Value;
            TemplateId  = Convert.ToInt32(element.Attribute("template").Value);
        }
コード例 #24
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);
        }
コード例 #25
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);
        }
コード例 #26
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"]);
        }
コード例 #27
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);
        }
コード例 #28
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);
        }
コード例 #29
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);
        }
コード例 #30
0
        public void EnumerateNodes()
        {
            var parser     = new UmbracoXmlParser(_tempFile);
            var enumerator = parser.GetNodes().GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual(1095, enumerator.Current.Id);
            Assert.AreEqual(1, enumerator.Current.Level);
            Assert.AreEqual("home", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1096, enumerator.Current.Id);
            Assert.AreEqual(2, enumerator.Current.Level);
            Assert.AreEqual("home/products", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1097, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/tattoo", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1097 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Tattoo" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1098, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/unicorn", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1098 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Unicorn" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1099, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/ping-pong-ball", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1099 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Ping Pong Ball" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1100, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/bowling-ball", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1100 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Bowling Ball" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1101, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/jumpsuit", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1101 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Jumpsuit" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1102, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/banjo", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1102 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Banjo" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1103, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/knitted-west", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1103 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Knitted West" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1104, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/products/biker-jacket", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1096, 1104 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Products", "Biker Jacket" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1105, enumerator.Current.Id);
            Assert.AreEqual(2, enumerator.Current.Level);
            Assert.AreEqual("home/people", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1106, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/people/jan-skovgaard", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105, 1106 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People", "Jan Skovgaard" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1107, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/people/matt-brailsford", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105, 1107 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People", "Matt Brailsford" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1108, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/people/lee-kelleher", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105, 1108 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People", "Lee Kelleher" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1109, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/people/jeavon-leopold", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105, 1109 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People", "Jeavon Leopold" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1110, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/people/jeroen-breuer", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1105, 1110 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "People", "Jeroen Breuer" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1111, enumerator.Current.Id);
            Assert.AreEqual(2, enumerator.Current.Level);
            Assert.AreEqual("home/about-us", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1111 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "About Us" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1112, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/about-us/about-this-starter-kit", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1111, 1112 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "About Us", "About this Starter Kit" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1113, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/about-us/todo-list-for-the-starter-kit", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1111, 1113 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "About Us", "Todo list for the Starter Kit" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1114, enumerator.Current.Id);
            Assert.AreEqual(2, enumerator.Current.Level);
            Assert.AreEqual("home/blog", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1114 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Blog" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1115, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/blog/my-blog-post", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1114, 1115 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Blog", "My Blog Post" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1116, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/blog/another-one", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1114, 1116 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Blog", "Another one" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1117, enumerator.Current.Id);
            Assert.AreEqual(3, enumerator.Current.Level);
            Assert.AreEqual("home/blog/this-will-be-great", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1114, 1117 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Blog", "This will be great" }, enumerator.Current.PathNames);

            enumerator.MoveNext();
            Assert.AreEqual(1118, enumerator.Current.Id);
            Assert.AreEqual(2, enumerator.Current.Level);
            Assert.AreEqual("home/contact", enumerator.Current.Url);
            CollectionAssert.AreEqual(new[] { 1095, 1118 }, enumerator.Current.PathIds);
            CollectionAssert.AreEqual(new[] { "Home", "Contact" }, enumerator.Current.PathNames);
        }