コード例 #1
0
 public void WhenXmlRootAttributeDecoratesAClassUseItAsTheRootElementName()
 {
     var foo = new FooWithXmlRootAttribute { Bar = "abc123" };
     var serializer = new XmlSerializer<FooWithXmlRootAttribute>();
     var xml = serializer.Serialize(foo);
     Assert.That(xml, Contains.Substring("<OMGWTFBBQ"));
     Assert.That(xml, Is.Not.ContainsSubstring("<FooWithXmlRootAttribute"));
 }
コード例 #2
0
 public void WhenXmlRootAttributeDecoratesButRootElementIsSuppliedByConstructorUseTheRootElementNameFromTheConstructor()
 {
     var foo = new FooWithXmlRootAttribute { Bar = "abc123" };
     var serializer = new XmlSerializer<FooWithXmlRootAttribute>(options => options.SetRootElementName("AndNowForSomethingCompletelyDifferent"));
     var xml = serializer.Serialize(foo);
     Assert.That(xml, Contains.Substring("<AndNowForSomethingCompletelyDifferent"));
     Assert.That(xml, Is.Not.ContainsSubstring("<OMGWTFBBQ"));
     Assert.That(xml, Is.Not.ContainsSubstring("<FooWithXmlRootAttribute"));
 }
コード例 #3
0
        public void WhenXmlRootAttributeDecoratesAClassUseItAsTheRootElementName()
        {
            var foo = new FooWithXmlRootAttribute {
                Bar = "abc123"
            };
            var serializer = new XmlSerializer <FooWithXmlRootAttribute>();
            var xml        = serializer.Serialize(foo);

            Assert.That(xml, Contains.Substring("<OMGWTFBBQ"));
            Assert.That(xml, Is.Not.ContainsSubstring("<FooWithXmlRootAttribute"));
        }
コード例 #4
0
        public void WhenXmlRootAttributeDecoratesButRootElementIsSuppliedByConstructorUseTheRootElementNameFromTheConstructor()
        {
            var foo = new FooWithXmlRootAttribute {
                Bar = "abc123"
            };
            var serializer = new XmlSerializer <FooWithXmlRootAttribute>(options => options.SetRootElementName("AndNowForSomethingCompletelyDifferent"));
            var xml        = serializer.Serialize(foo);

            Assert.That(xml, Contains.Substring("<AndNowForSomethingCompletelyDifferent"));
            Assert.That(xml, Is.Not.ContainsSubstring("<OMGWTFBBQ"));
            Assert.That(xml, Is.Not.ContainsSubstring("<FooWithXmlRootAttribute"));
        }