-Changed DataContractAttribute on collections back to array serialization
-Fixed JObject.GetPropertyOwner to return value -Fixed JPropertyDescriptor GetValue and SetValue to return null for null owner
This commit is contained in:
@@ -50,6 +50,14 @@ namespace Newtonsoft.Json.Tests.Linq.ComponentModel
|
||||
Assert.AreEqual(o["prop2"], prop2.GetValue(o));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValue_NullOwner_ReturnsNull()
|
||||
{
|
||||
JPropertyDescriptor prop1 = new JPropertyDescriptor("prop1");
|
||||
|
||||
Assert.AreEqual(null, prop1.GetValue(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetValue()
|
||||
{
|
||||
@@ -62,6 +70,14 @@ namespace Newtonsoft.Json.Tests.Linq.ComponentModel
|
||||
Assert.AreEqual("54321!", (string)o["prop1"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetValue_NullOwner_NoError()
|
||||
{
|
||||
JPropertyDescriptor prop1 = new JPropertyDescriptor("prop1");
|
||||
|
||||
prop1.SetValue(null, "value!");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResetValue()
|
||||
{
|
||||
|
||||
@@ -2040,5 +2040,28 @@ Parameter name: arrayIndex");
|
||||
ExceptionAssert.Throws<JsonReaderException>(() => JObject.Parse(json),
|
||||
"Additional text encountered after finished reading JSON content: [. Path '', line 3, position 0.");
|
||||
}
|
||||
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40) || NETSTANDARD2_0
|
||||
[Test]
|
||||
public void GetPropertyOwner_ReturnsJObject()
|
||||
{
|
||||
ICustomTypeDescriptor o = new JObject
|
||||
{
|
||||
["prop1"] = 1
|
||||
};
|
||||
|
||||
PropertyDescriptorCollection properties = o.GetProperties();
|
||||
Assert.AreEqual(1, properties.Count);
|
||||
|
||||
PropertyDescriptor pd = properties[0];
|
||||
Assert.AreEqual("prop1", pd.Name);
|
||||
|
||||
object owner = o.GetPropertyOwner(pd);
|
||||
Assert.AreEqual(o, owner);
|
||||
|
||||
object value = pd.GetValue(owner);
|
||||
Assert.AreEqual(1, (int)(JToken)value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user