public void TestDateTimePropertyToXml() { var serializable = new WithDateTimeNullableProperty() { AnyDateTime = null }; var xml = serializable.ToXml(provider: CultureInfo.InvariantCulture); var doc = XDocument.Parse(xml); var element = doc.XPathSelectElement("/Date/AnyDate"); Assert.AreEqual("", element.Value); }
public void TestDateTimePropertyToXml() { var expectedDate = new DateTime(2012, 10, 13, 16, 30, 55, 123); var serializable = new WithDateTimeNullableProperty() { AnyDateTime = expectedDate }; var xml = serializable.ToXml(provider: CultureInfo.InvariantCulture); var doc = XDocument.Parse(xml); var element = doc.XPathSelectElement("/Date/AnyDate"); Assert.AreEqual(expectedDate.ToString("yyyy/MM/dd HH:mm:ss:fff", CultureInfo.InvariantCulture), element.Value); }