public void TestBasicNoVersionXMLCharacters() { // Create the object. var xmlObject = new BasicNoVersion(); xmlObject.TestAttribute1 = 1; xmlObject.TestAttribute2 = "Test 1>"; xmlObject.TestElement1 = 2; xmlObject.TestElement2 = "Test <2"; // Assert the element is generated correctly. Assert.AreEqual(xmlObject.Serialize(new XMLVersion()), "<TestXMLElement testAttribute1=\"1\" testAttribute2=\"Test 1>\"><testElement1>2</testElement1><testElement2>Test <2</testElement2></TestXMLElement>"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion(), "CustomName"), "<CustomName testAttribute1=\"1\" testAttribute2=\"Test 1>\"><testElement1>2</testElement1><testElement2>Test <2</testElement2></CustomName>"); }
public void TestNesting() { // Create the objects. var xmlObject1 = new BasicNoVersion(); xmlObject1.TestAttribute1 = 1; xmlObject1.TestAttribute2 = "Test 1"; xmlObject1.TestElement1 = 2; xmlObject1.TestElement2 = "Test 2"; var xmlObject2 = new NestingElement(); xmlObject2.TestAttribute = 1; xmlObject2.TestElement1 = 2; xmlObject2.TestElement2 = xmlObject1; // Assert the element is generated correctly. Assert.AreEqual(xmlObject2.Serialize(new XMLVersion()), "<NestingXMLElement testAttribute=\"1\"><testElement1>2</testElement1><testElement2 testAttribute1=\"1\" testAttribute2=\"Test 1\"><testElement1>2</testElement1><testElement2>Test 2</testElement2></testElement2></NestingXMLElement>"); }
public void TestBasicNoVersion() { // Create the object. var xmlObject = new BasicNoVersion(); xmlObject.TestAttribute1 = 1; xmlObject.TestAttribute2 = "Test 1"; xmlObject.TestElement1 = 2; xmlObject.TestElement2 = "Test 2"; // Assert the element is generated correctly. Assert.AreEqual(xmlObject.Serialize(new XMLVersion()), "<TestXMLElement testAttribute1=\"1\" testAttribute2=\"Test 1\"><testElement1>2</testElement1><testElement2>Test 2</testElement2></TestXMLElement>"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion(), "CustomName"), "<CustomName testAttribute1=\"1\" testAttribute2=\"Test 1\"><testElement1>2</testElement1><testElement2>Test 2</testElement2></CustomName>"); // Add an additional attribute and assert it is generated correctly. xmlObject.SetAdditionalAttribute("testAttribute3", "test"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion()), "<TestXMLElement testAttribute1=\"1\" testAttribute2=\"Test 1\" testAttribute3=\"test\"><testElement1>2</testElement1><testElement2>Test 2</testElement2></TestXMLElement>"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion(), "CustomName"), "<CustomName testAttribute1=\"1\" testAttribute2=\"Test 1\" testAttribute3=\"test\"><testElement1>2</testElement1><testElement2>Test 2</testElement2></CustomName>"); // Add an additional element and assert it is generated correctly. xmlObject.AddAdditionalElement("<testElement3>Test 3</testElement3>"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion()), "<TestXMLElement testAttribute1=\"1\" testAttribute2=\"Test 1\" testAttribute3=\"test\"><testElement1>2</testElement1><testElement2>Test 2</testElement2><testElement3>Test 3</testElement3></TestXMLElement>"); Assert.AreEqual(xmlObject.Serialize(new XMLVersion(), "CustomName"), "<CustomName testAttribute1=\"1\" testAttribute2=\"Test 1\" testAttribute3=\"test\"><testElement1>2</testElement1><testElement2>Test 2</testElement2><testElement3>Test 3</testElement3></CustomName>"); }