Ejemplo n.º 1
0
        public void Should_add_another_child()
        {
            var rootNode = new Node("/");
            rootNode.AddPath("/home/sports/");
            rootNode.AddPath("/home/music/");

            var anotherChild = rootNode.GetChildren()[0].GetChildren()[1];

            Assert.That(anotherChild.ToString(), Is.EqualTo("music"));
        }
Ejemplo n.º 2
0
        public void Should_add_first_child()
        {
            var rootNode = new Node("/");
            var firstChild = rootNode.AddPath("/home/sports/");

            Assert.That(firstChild.GetChildren()[0].ToString(), Is.EqualTo("sports"));
        }
Ejemplo n.º 3
0
        public void Should_add_root()
        {
            var rootNode = new Node("/");

            var node = rootNode.AddPath("/home/");

            Assert.That(node.ToString(), Is.EqualTo("home"));
        }
Ejemplo n.º 4
0
        public void Should_support_combinatorial_leafs_at_any_level()
        {
            var rootNode = new Node("/");
            rootNode.AddPath("/home/sports|music/misc|favorites");

            AssertNodeExists(rootNode.FindNode("home"), "sports");
            AssertNodeExists(rootNode.FindNode("home"), "music");

            AssertNodeExists(rootNode.FindNode("home").FindNode("music"), "misc");
            AssertNodeExists(rootNode.FindNode("home").FindNode("music"), "favorites");
            AssertNodeExists(rootNode.FindNode("home").FindNode("music"), "misc-favorites");

            AssertNodeExists(rootNode.FindNode("home").FindNode("sports"), "misc");
            AssertNodeExists(rootNode.FindNode("home").FindNode("sports"), "favorites");
            AssertNodeExists(rootNode.FindNode("home").FindNode("sports"), "misc-favorites");

            AssertNodeExists(rootNode.FindNode("home").FindNode("sports-music"), "misc");
            AssertNodeExists(rootNode.FindNode("home").FindNode("sports-music"), "favorites");
            AssertNodeExists(rootNode.FindNode("home").FindNode("sports-music"), "misc-favorites");
        }
Ejemplo n.º 5
0
        public void Should_add_many_children_and_grand_children()
        {
            var rootNode = new Node("/");
            rootNode.AddPath("/home/sports/basketball");
            rootNode.AddPath("/home/sports/football");
            rootNode.AddPath("/home/sports/basketball/NCAA");

            rootNode.AddPath("/home/music/");
            rootNode.AddPath("/home/music/rap");
            rootNode.AddPath("/home/music/rock");
            rootNode.AddPath("/home/music/rap/gangster");

            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].ToString(), Is.EqualTo("sports"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].GetChildren()[0].ToString(), Is.EqualTo("basketball"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].GetChildren()[1].ToString(), Is.EqualTo("football"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].GetChildren()[0].GetChildren()[0].ToString(), Is.EqualTo("NCAA"));

            Assert.That(rootNode.GetChildren()[0].GetChildren()[1].ToString(), Is.EqualTo("music"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[1].GetChildren()[0].ToString(), Is.EqualTo("rap"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[1].GetChildren()[1].ToString(), Is.EqualTo("rock"));
            Assert.That(rootNode.GetChildren()[0].GetChildren()[1].GetChildren()[0].GetChildren()[0].ToString(), Is.EqualTo("gangster"));
        }
Ejemplo n.º 6
0
        public void Should_support_dual_leaf_nodes()
        {
            var rootNode = new Node("/");
            rootNode.AddPath("/home/sports/basketball");
            rootNode.AddPath("/home/sports/football");
            rootNode.AddPath("/home/sports/basketball/NCAA");
            rootNode.AddPath("/home/sports/football/NFL|NCAA");

            Assert.That(rootNode.GetChildren()[0].FindNode("sports"), Is.Not.Null);
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].FindNode("basketball"), Is.Not.Null);
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].FindNode("football"), Is.Not.Null);
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].GetChildren()[1].FindNode("NFL"), Is.Not.Null);
            Assert.That(rootNode.GetChildren()[0].GetChildren()[0].GetChildren()[1].FindNode("NCAA"), Is.Not.Null);
        }
Ejemplo n.º 7
0
        public void Should_support_combinatorial_leaf_node_insert()
        {
            var rootNode = new Node("/");
            rootNode.AddPath("/home/music/rap|rock|pop");

            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rap");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rock");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "pop");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rap-rock");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rap-pop");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rock-pop");
            AssertNodeExists(rootNode.GetChildren()[0].GetChildren()[0], "rap-rock-pop");
        }