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()); }
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); }
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); }
public void TestCompositeTagoneChild() { String expected = "<product>" + "<price/>" + "</product>"; TagNode productTag = new TagNode("product"); productTag.Add(new TagNode("price")); Assert.AreEqual(expected, productTag.ToString()); }
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); }
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"); }
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()); }
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); }