public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <STATACCOUNT> <ACCOUNTNO>9000</ACCOUNTNO> <TITLE>hello world</TITLE> <ACCOUNTTYPE>forperiod</ACCOUNTTYPE> </STATACCOUNT> </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); StatisticalAccountCreate record = new StatisticalAccountCreate("unittest"); record.AccountNo = "9000"; record.Title = "hello world"; record.ReportType = "forperiod"; 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 GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <create> <STATACCOUNT> <ACCOUNTNO>9000</ACCOUNTNO> <TITLE>hello world</TITLE> <ACCOUNTTYPE>forperiod</ACCOUNTTYPE> </STATACCOUNT> </create> </function>"; StatisticalAccountCreate record = new StatisticalAccountCreate("unittest") { AccountNo = "9000", Title = "hello world", ReportType = "forperiod" }; this.CompareXml(expected, record); }