public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <ALLOCATION> <ALLOCATIONID>SPLIT60-40</ALLOCATIONID> <TYPE>Percentage</TYPE> </ALLOCATION> </create> </function>"; AllocationCreate record = new AllocationCreate("unittest") { AllocationId = "SPLIT60-40", AllocateBy = "Percentage" }; this.CompareXml(expected, record); }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <ALLOCATION> <ALLOCATIONID>SPLIT60-40</ALLOCATIONID> <TYPE>Percentage</TYPE> </ALLOCATION> </create> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); AllocationCreate record = new AllocationCreate("unittest"); record.AllocationId = "SPLIT60-40"; record.AllocateBy = "Percentage"; record.WriteXml(ref xml); xml.Flush(); stream.Position = 0; StreamReader reader = new StreamReader(stream); Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd()) .WithDifferenceEvaluator(DifferenceEvaluators.Default) .Build(); Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString()); }