public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <lineitem> <glaccountno /> <amount>76343.43</amount> </lineitem>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); OtherReceiptLineCreate line = new OtherReceiptLineCreate(); line.TransactionAmount = 76343.43M; line.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""?> <lineitem> <accountlabel>TestBill Account1</accountlabel> <amount>76343.43</amount> <memo>Just another memo</memo> <locationid>Location1</locationid> <departmentid>Department1</departmentid> <customfields> <customfield> <customfieldname>customfield1</customfieldname> <customfieldvalue>customvalue1</customfieldvalue> </customfield> </customfields> <projectid>Project1</projectid> <customerid>Customer1</customerid> <vendorid>Vendor1</vendorid> <employeeid>Employee1</employeeid> <itemid>Item1</itemid> <classid>Class1</classid> <contractid>Contract1</contractid> <warehouseid>Warehouse1</warehouseid> </lineitem>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); OtherReceiptLineCreate line = new OtherReceiptLineCreate(); line.AccountLabel = "TestBill Account1"; line.TransactionAmount = 76343.43M; line.Memo = "Just another memo"; line.LocationId = "Location1"; line.DepartmentId = "Department1"; line.ProjectId = "Project1"; line.CustomerId = "Customer1"; line.VendorId = "Vendor1"; line.EmployeeId = "Employee1"; line.ItemId = "Item1"; line.ClassId = "Class1"; line.ContractId = "Contract1"; line.WarehouseId = "Warehouse1"; line.CustomFields = new Dictionary <string, dynamic> { { "customfield1", "customvalue1" } }; line.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()); }