public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <subtotal> <description>Subtotal Description</description> <total>2340</total> </subtotal>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); TransactionSubtotalCreate record = new TransactionSubtotalCreate() { Description = "Subtotal Description", Total = 2340, }; 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()); }
public void GetAllXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <subtotal> <description>Subtotal Description</description> <total>4202</total> <percentval>9.2</percentval> <locationid>2355</locationid> <departmentid>RCVNG</departmentid> <projectid>FOW</projectid> <customerid>CUST5893</customerid> <vendorid>VEN53222</vendorid> <employeeid>EM5925</employeeid> <classid>CLS322</classid> <itemid>I5266235</itemid> <contractid>C23662</contractid> <customfields> <customfield> <customfieldname>customfield1</customfieldname> <customfieldvalue>customvalue1</customfieldvalue> </customfield> </customfields> </subtotal>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); TransactionSubtotalCreate record = new TransactionSubtotalCreate() { Description = "Subtotal Description", Total = 4202, PercentageValue = 9.2M, LocationId = "2355", DepartmentId = "RCVNG", ProjectId = "FOW", CustomerId = "CUST5893", VendorId = "VEN53222", EmployeeId = "EM5925", ClassId = "CLS322", ItemId = "I5266235", ContractId = "C23662", CustomFields = new Dictionary <string, dynamic> { { "customfield1", "customvalue1" } } }; 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()); }