public void XmlStringValid() { string value = Mapper.MapToXmlString(Instance); Assert.DoesNotThrow(() => { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(value); }, "Generated Xml string is invalid", null); }
static void Main(string[] args) { List <CustomLoan> loans = new List <CustomLoan>(); for (int i = 0; i < 1000; i++) { loans.Add(new CustomLoan() { Name = "Revolving Loan", Amount = 25000, IsJointAccount = true, ProductCode = "RLP", Applicant = new Applicant() { FirstName = "George", LastName = "Bush" }, Application = new Application() { ApplicationID = 1, CreateDate = new DateTime(2018, 5, 22), Name = "New Application" }, Listing = new List <string>() { "string", "another", "text" }, CustomFieldA = "Custom Data For Client Here", CustomFieldB = "Custom Other Data For Client Here", Dictionary = new Dictionary <string, UnMarked>() { { "KeyA", new UnMarked() { UnmarkedFieldA = 20, UnmarkedFieldB = 3.14564 } }, { "KeyB", new UnMarked() { UnmarkedFieldA = 77, UnmarkedFieldB = 16.981357 } }, { "KeyC", new UnMarked() { UnmarkedFieldA = 86486, UnmarkedFieldB = -1.1384 } } }, JointApplicants = new LinkedList <Applicant>(new List <Applicant> { new Applicant() { FirstName = "Jemma", LastName = "Busher" }, new Applicant() { FirstName = "Harrison", LastName = "Bushmaster" } }), FlattenThisProperty = new UnMarked() { UnmarkedFieldA = 777, UnmarkedFieldB = 312 } }); } var xmlMapper = new XmlMapper <CustomLoan>(); string values = ""; Stopwatch watch = Stopwatch.StartNew(); foreach (CustomLoan loan in loans) { values = xmlMapper.MapToXmlString(loan); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); Console.WriteLine(values); XmlDocument xml = new XmlDocument(); xml.LoadXml(values); CustomLoan mappedBackObject = xmlMapper.MapToObject(xml); //Console.WriteLine("Serialization"); //Console.WriteLine(ToXML(loans[0])); Console.ReadKey(); return; }