コード例 #1
0
        public void TheXmlArrayItemAttributeDefinedInInterfaceIsUsed()
        {
            var serializer = new XmlSerializer <HasXmlArrayItemAttribute>(x => x.ShouldUseAttributeDefinedInInterface());

            var item = new HasXmlArrayItemAttribute
            {
                Bazes = new List <Baz> {
                    new Baz {
                        Qux = "abc"
                    }, new Baz {
                        Qux = "xyz"
                    }
                }
            };

            var xml = serializer.Serialize(item);

            Assert.That(xml, Is.Not.StringContaining("<Baz>"));
            Assert.That(xml, Is.StringContaining("<Bar>"));
        }
コード例 #2
0
        public void TheXmlArrayItemAttributeDefinedInInterfaceIsUsed()
        {
            var serializer = new XmlSerializer<HasXmlArrayItemAttribute>(x => x.ShouldUseAttributeDefinedInInterface());

            var item = new HasXmlArrayItemAttribute
            {
                Bazes = new List<Baz> { new Baz { Qux = "abc" }, new Baz { Qux = "xyz" } }
            };

            var xml = serializer.Serialize(item);

            Assert.That(xml, Is.Not.StringContaining("<Baz>"));
            Assert.That(xml, Is.StringContaining("<Bar>"));
        }