예제 #1
0
        public void WriteXmlWithKnownTypePropertyTest()
        {
            var value = new ClassWithKnownTypeProperty
            {
                Name = "test",
                Foo  = new FooBar
                {
                    Id   = 1,
                    Name = "foobar"
                }
            };

            var actual   = GetConverter().ToXml(value);
            var expected = @"<xml><name>test</name><fooBar><id>1</id><name>foobar</name></fooBar></xml>";

            Assert.That(actual, IsXml.Equals(expected));
        }
예제 #2
0
        public void ReadXmlWithKnownTypePropertyTest()
        {
            var xml = @"<xml><name>test</name><fooBar><id>1</id><name>foobar</name></fooBar></xml>";

            var expected = new ClassWithKnownTypeProperty
            {
                Name = "test",
                Foo  = new FooBar
                {
                    Id   = 1,
                    Name = "foobar"
                }
            };

            var actual = GetConverter().ParseXml <ClassWithKnownTypeProperty>(xml);

            Assert.AreEqual(expected, actual);
        }