public void GetAllXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <readByName> <object>GLENTRY</object> <keys>987</keys> <fields>TRX_AMOUNT,RECORDNO,BATCHNO</fields> <returnFormat>xml</returnFormat> <docparid>Sales Invoice</docparid> </readByName> </function>"; ReadByName record = new ReadByName("unittest") { ObjectName = "GLENTRY", Fields = new List <string> { "TRX_AMOUNT", "RECORDNO", "BATCHNO", }, Names = new List <string> { "987", }, DocParId = "Sales Invoice" }; this.CompareXml(expected, record); }
public void ParamOverridesTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <readByName> <object>GLENTRY</object> <keys>987</keys> <fields>TRX_AMOUNT,RECORDNO,BATCHNO</fields> <returnFormat>xml</returnFormat> <docparid>Sales Invoice</docparid> </readByName> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); ReadByName readByName = new ReadByName("unittest"); readByName.ObjectName = "GLENTRY"; readByName.ReturnFormat = "xml"; readByName.Fields = new List <string> { "TRX_AMOUNT", "RECORDNO", "BATCHNO", }; readByName.Names = new List <string> { "987", }; readByName.DocParId = "Sales Invoice"; readByName.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 InvalidReturnFormatTest() { Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); ReadByName readByName = new ReadByName("unittest"); readByName.ObjectName = "CLASS"; readByName.ReturnFormat = "blah"; }
public void GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <readByName> <object>GLENTRY</object> <keys /> <fields>*</fields> <returnFormat>xml</returnFormat> </readByName> </function>"; ReadByName record = new ReadByName("unittest") { ObjectName = "GLENTRY" }; this.CompareXml(expected, record); }
public void TooManyNamesTest() { ReadByName record = new ReadByName("unittest") { ObjectName = "GLENTRY" }; List <string> names = new List <string>(); for (int i = 1; i <= 101; i++) { names.Add(i.ToString()); } var ex = Record.Exception(() => record.Names = names); Assert.IsType <ArgumentException>(ex); Assert.Equal("Names count cannot exceed 100", ex.Message); }
public void TooManyNamesTest() { Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); ReadByName readByName = new ReadByName("unittest"); readByName.ObjectName = "CLASS"; List <string> names = new List <string>(); for (int i = 1; i <= 101; i++) { names.Add(i.ToString()); } readByName.Names = names; }
public void DefaultParamsTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <function controlid=""unittest""> <readByName> <object>GLENTRY</object> <keys /> <fields>*</fields> <returnFormat>xml</returnFormat> </readByName> </function>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); ReadByName readbyName = new ReadByName("unittest"); readbyName.ObjectName = "GLENTRY"; readbyName.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()); }