public void TestXDocumentToXml()
        {
            var serializable = new WithFloatPointNumericProperty()
            {
                AnySingle = Single.MaxValue,
                AnyDouble = Single.MinValue
            };

            var xml    = serializable.ToXml(provider: CultureInfo.InvariantCulture.NumberFormat);
            var xmlDoc = serializable.ToXmlDocument(provider: CultureInfo.InvariantCulture.NumberFormat);

            Assert.AreEqual(xml, xmlDoc.ToString());
        }
예제 #2
0
        public void TestFloatPointNumericPropertyToXml()
        {
            var serializable = new WithFloatPointNumericProperty()
            {
                AnySingle = 3.402823E+38f,
                AnyDouble = 1.79769313486231E+308,
            };

            var xml = serializable.ToXml(provider: CultureInfo.InvariantCulture.NumberFormat);

            var doc           = XDocument.Parse(xml);
            var elementSingle = doc.XPathSelectElement("/Numeric/AnySingle");
            var elementDouble = doc.XPathSelectElement("/Numeric/AnyDouble");

            Assert.AreEqual((3.402823E+38f).ToString("N", CultureInfo.InvariantCulture.NumberFormat), elementSingle.Value);
            Assert.AreEqual((1.79769313486231E+308).ToString("N", CultureInfo.InvariantCulture.NumberFormat), elementDouble.Value);
        }