コード例 #1
0
        public void TestStringPropertyToXml()
        {
            var serializable = new WithStringProperty()
            {
                AnyString = "MyString"
            };

            var xml = serializable.ToXml();

            var doc     = XDocument.Parse(xml);
            var element = doc.XPathSelectElement("/String/AnyString");

            Assert.AreEqual("MyString", element.Value);
        }
        public void TestStringOptionalPropertyToXml()
        {
            var serializable = new WithStringProperty()
            {
                AnyString = null
            };

            var xml = serializable.ToXml();

            var doc     = XDocument.Parse(xml);
            var element = doc.XPathSelectElement("/String/AnyString");

            // Check that element is NOT created
            Assert.IsNull(element);
        }