-Added JsonConstructorAttribute to explicitly define which constructor to use during deserialization
-Added IFormattable to JValue -Changed JValue ToString to call ToString on the internal value -Fixed code emit error when deserializing interfaces in certain situations
This commit is contained in:
@@ -29,6 +29,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Linq
|
||||
{
|
||||
@@ -92,6 +93,30 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual(JTokenType.String, stringValue.Type);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToString()
|
||||
{
|
||||
JValue v;
|
||||
|
||||
v = new JValue(true);
|
||||
Assert.AreEqual("True", v.ToString());
|
||||
|
||||
v = new JValue(Encoding.UTF8.GetBytes("Blah"));
|
||||
Assert.AreEqual("System.Byte[]", v.ToString(null, CultureInfo.InvariantCulture));
|
||||
|
||||
v = new JValue("I am a string!");
|
||||
Assert.AreEqual("I am a string!", v.ToString());
|
||||
|
||||
v = new JValue(null, JTokenType.Null);
|
||||
Assert.AreEqual("", v.ToString());
|
||||
|
||||
v = new JValue(null, JTokenType.Null);
|
||||
Assert.AreEqual("", v.ToString(null, CultureInfo.InvariantCulture));
|
||||
|
||||
v = new JValue(new DateTime(2000, 12, 12, 20, 59, 59, DateTimeKind.Utc), JTokenType.Date);
|
||||
Assert.AreEqual("12/12/2000 20:59:59", v.ToString(null, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Cannot access child value on Newtonsoft.Json.Linq.JValue.")]
|
||||
public void Last()
|
||||
|
||||
Reference in New Issue
Block a user