Beispiel #1
0
        public void GetChild_WithManyChildren()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", root);
            AnItem item3 = CreateOneItem <AnItem>(4, "item3", root);

            Assert.AreEqual(item1, root.GetChild("item1"));
            Assert.AreEqual(item2, root.GetChild("item2"));
            Assert.AreEqual(item3, root.GetChild("item3"));
        }
Beispiel #2
0
        public void GetChild_WhenName_IncludesUnicodeCharacter()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "ännu en ångande ö", root);

            Assert.AreEqual(item1, root.GetChild("ännu en ångande ö"));
        }
Beispiel #3
0
        public void GetChild_NameIncluding_Slash_IsFound()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);

            Assert.That(root.GetChild("item.1/"), Is.EqualTo(item1));
        }
Beispiel #4
0
        public void GetChild_NameIncludingDot()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);

            Assert.AreEqual(item1, root.GetChild("item.1"));
        }
Beispiel #5
0
        public void GetChild_WithEmptyStringDoesntThrowException()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);

            Assert.IsNull(root.GetChild(string.Empty));
        }
Beispiel #6
0
        public void GetChild_NoItemYeldsNull()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);

            Assert.IsNull(root.GetChild("item2"));
        }
Beispiel #7
0
        public void GetChild_FindGrandChild_WhenTrailingSlash()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);

            Assert.AreEqual(root.GetChild("item1/item2/"), item2);
        }
Beispiel #8
0
        public void GetChild_CanFindCurrentItem()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);

            Assert.AreEqual(root.GetChild("/"), root);
        }
Beispiel #9
0
        public void GetChildsChildWithTrailContainingDots()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item.1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.AreEqual(item2, root.GetChild("item.1/item2"));
        }
Beispiel #10
0
        public void FindsGrandChild_WhenTrailingAspx()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.That(root.GetChild("item1/item2/"), Is.EqualTo(item2));
        }
Beispiel #11
0
        public void GetChildsChild()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(2, "item2", item1);

            Assert.AreEqual(item2, root.GetChild("item1/item2"));
        }
Beispiel #12
0
        public void GetChild_HolesInPathYeldsNull()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item1", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item2", item1);
            AnItem item3 = CreateOneItem <AnItem>(4, "item3", item2);

            Assert.IsNull(root.GetChild("item1/itemX/item3"));
        }
Beispiel #13
0
        public void GetAncestorWayDown()
        {
            AnItem root  = CreateOneItem <AnItem>(1, "root", null);
            AnItem item1 = CreateOneItem <AnItem>(2, "item", root);
            AnItem item2 = CreateOneItem <AnItem>(3, "item", item1);
            AnItem item3 = CreateOneItem <AnItem>(4, "item", item2);
            AnItem item4 = CreateOneItem <AnItem>(5, "item", item3);
            AnItem item5 = CreateOneItem <AnItem>(6, "item", item4);
            AnItem item6 = CreateOneItem <AnItem>(7, "item", item5);
            AnItem item7 = CreateOneItem <AnItem>(8, "item", item6);
            AnItem item8 = CreateOneItem <AnItem>(9, "item", item7);

            Assert.AreEqual(item2, root.GetChild("item/item"));
            Assert.AreEqual(item2, root.GetChild("item").GetChild("item"));
            Assert.AreEqual(item4, root.GetChild("item/item/item/item"));
            Assert.AreEqual(item4, root.GetChild("item/item").GetChild("item/item"));
            Assert.AreEqual(item8, root.GetChild("item/item/item/item").GetChild("item/item/item/item"));
            Assert.AreEqual(item8, root.GetChild("item/item/item/item/item/item/item/item"));
        }