Ejemplo n.º 1
0
        public void ReadWriteTest()
        {
            var obj1 = new FormatModel {
                Age = 18, Name = "老九"
            };
            var formatter = new WebApiClientCore.Serialization.XmlSerializer();
            var xml       = formatter.Serialize(obj1, Encoding.UTF8);
            var obj2      = formatter.Deserialize(xml, typeof(FormatModel));

            Assert.True(obj1.Equals(obj2));
        }
Ejemplo n.º 2
0
        public void EncodingTest()
        {
            var obj1 = new FormatModel {
                Age = 18, Name = "老九"
            };
            var formatter = new WebApiClientCore.Serialization.XmlSerializer();

            var opt = new System.Xml.XmlWriterSettings
            {
                Encoding = Encoding.Unicode
            };

            var xml = formatter.Serialize(obj1, opt);

            Assert.Contains(opt.Encoding.WebName, xml);
        }