Пример #1
0
        public void Test_FromXml()
        {
            // get xml string 
            string xmlString = WriteHelper.CreateXmlText(mData);

            var xml = new XmlDocument();
            xml.LoadXml(xmlString);

            var objBuilder = new ObjectBuilder();
            objBuilder.RegisterAssembly(this.GetType().Assembly);

            // back to object
            object obj = objBuilder.CreateObjectFromXml(xml.DocumentElement);

            Assert.AreEqual(obj != null, true);

            var a = obj as A;

            Assert.AreEqual(a != null, true);
            Assert.AreEqual(a.ID, 999);
            Assert.AreEqual(a.Data != null, true);
            Assert.AreEqual(a.Data.Amount, 123.45);
            Assert.AreEqual(a.Enabled, true);
            Assert.AreEqual(a.MultiValues.Length, 3);
            Assert.AreEqual(a.MultiValues[0], "aaa");

        }