Adds test for deserializing XmlElement and a minor change in the exception message

This commit is contained in:
Jack Ma
2016-04-22 11:00:11 -07:00
parent 795b9e3a46
commit 096b8f3576
2 changed files with 18 additions and 1 deletions
@@ -906,6 +906,23 @@ namespace Newtonsoft.Json.Tests.Converters
return sw.ToString();
}
public class Foo2
{
public XmlElement Bar { get; set; }
}
[Test]
public void SerializeAndDeserializeXmlElement()
{
Foo2 foo = new Foo2 { Bar = null };
string json = JsonConvert.SerializeObject(foo);
Assert.AreEqual(@"{""Bar"":null}", json);
Foo2 foo2 = JsonConvert.DeserializeObject<Foo2>(json);
Assert.IsNull(foo2.Bar);
}
[Test]
public void SingleTextNode()
{
@@ -1433,7 +1433,7 @@ namespace Newtonsoft.Json.Converters
{
if (objectType != typeof(XmlDocument) && objectType != typeof(XmlElement))
{
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocuments or XmlElement");
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocument or XmlElement");
}
XmlDocument d = new XmlDocument();