Clean up merge changes

This commit is contained in:
James Newton-King
2019-08-18 18:07:53 +12:00
parent da0f0d8dd1
commit 84b5c15eab
2 changed files with 20 additions and 2 deletions
+18 -2
View File
@@ -47,11 +47,27 @@ namespace Newtonsoft.Json.Tests.Linq
public class MergeTests : TestFixtureBase
{
[Test]
public void MergeSelf()
public void MergeArraySelf()
{
var a = new JArray { "1", "2" };
a.Merge(a, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace });
Assert.AreEqual(a, new JArray { "1", "2" });
Assert.AreEqual(new JArray { "1", "2" }, a);
}
[Test]
public void MergeObjectSelf()
{
var a = new JObject
{
["1"] = 1,
["2"] = 2
};
a.Merge(a, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace });
Assert.AreEqual(new JObject
{
["1"] = 1,
["2"] = 2
}, a);
}
[Test]
+2
View File
@@ -1165,7 +1165,9 @@ namespace Newtonsoft.Json.Linq
break;
case MergeArrayHandling.Replace:
if (target == content)
{
break;
}
target.ClearItems();
foreach (JToken item in content)
{