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"));
 }
 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"));
 }
Exemple #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"));
        }
Exemple #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"));
        }