Exemplo n.º 1
0
        public void Adding_A_Child_Node_Should_Get_Included_In_Its_String_Representation()
        {
            var expected = "<parent gender='female'>Jennifer" +
                           "<child gender='male'>John</child>" +
                           "</parent>";

            _tagNode.Add(new TagNode("child", "gender='male'", "John"));

            Assert.AreEqual(expected, _tagNode.ToString());
        }
Exemplo n.º 2
0
        public void TestAddChildrenToTree()
        {
            string  expectedResult = "<orders><order><item></item></order></orders>";
            TagNode orders         = new TagNode("orders");
            TagNode order          = new TagNode("order");
            TagNode item           = new TagNode("item");

            order.Add(item);
            orders.Add(order);
            Assert.Equal(orders.ToString(), expectedResult);
        }
Exemplo n.º 3
0
        public void TestParents()
        {
            TagNode root = new TagNode("root");

            Assert.Null(root.ParentNode);

            TagNode childNode = new TagNode("child");

            root.Add(childNode);

            Assert.AreEqual(root, childNode.ParentNode);
            Assert.AreEqual("root", childNode.ParentNode.Name);
        }
Exemplo n.º 4
0
        public void TestCompositeTagoneChild()
        {
            String expected =
                "<product>" +
                "<price/>" +
                "</product>";

            TagNode productTag = new TagNode("product");

            productTag.Add(new TagNode("price"));

            Assert.AreEqual(expected, productTag.ToString());
        }
Exemplo n.º 5
0
        public void TestAddAttributesAndValuesToTree()
        {
            string expectedResult = "<orders><order><item quantity='1' number='1234'>" +
                                    "DogHouse</item></order></orders>";
            TagNode orders = new TagNode("orders");
            TagNode order  = new TagNode("order");
            TagNode item   = new TagNode("item");

            item.AddAttributes("quantity", "1");
            item.AddAttributes("number", "1234");
            item.SetValue("DogHouse");

            order.Add(item);
            orders.Add(order);
            Assert.Equal(orders.ToString(), expectedResult);
        }
Exemplo n.º 6
0
        public void Test_CompositeTag_OneChild()
        {
            // Arrange
            String expected =
                "<product>" +
                "<price>" +
                "</price>" +
                "</product>";

            // Act
            TagNode productTag = new TagNode("product");

            productTag.Add(new TagNode("price"));

            // Assert
            Assert.AreEqual(expected, productTag.ToString(), "price XML");
        }
Exemplo n.º 7
0
        public void TestAddingChildrenAndGrandChildren()
        {
            String expected =
                "<orders>" +
                "<order>" +
                "<product/>" +
                "</order>" +
                "</orders>";

            TagNode ordersTag = new TagNode("orders");
            TagNode orderTag  = new TagNode("order");

            orderTag.Add(new TagNode("product"));
            ordersTag.Add(orderTag);

            Assert.AreEqual(expected, ordersTag.ToString());
        }
Exemplo n.º 8
0
        public void Test_AddingChildren_And_GrandChildren()
        {
            // Arrange
            String expected =
                "<orders>" +
                "<order>" +
                "<product>" +
                "</product>" +
                "</order>" +
                "</orders>";

            // Act
            TagNode ordersTag  = new TagNode("orders");
            TagNode orderTag   = new TagNode("order");
            TagNode productTag = new TagNode("product");

            ordersTag.Add(orderTag);
            orderTag.Add(productTag);

            // Assert
            Assert.AreEqual(expected, ordersTag.ToString(), "price XML");
        }
 private void AddTo(TagNode parentNode, string tagName)
 {
     _currentNode = new TagNode(tagName);
     parentNode.Add(_currentNode);
 }