Hi,
I have an issue when creating diffpatches on my objects after I have modified a sub-collection on those objects. It all works fine as long as I add or remove items to the collection, but not when I both and and remove items. I've create a very simple unit test that demonstrates this. Is this an issue or "expected behavior" ?
Test:
`
public class MyClass
{
public List MyList { get; set; }
}
[TestClass]
public class AddRemoveDiffPatchTests
{
[TestMethod]
public void Test()
{
var differ = new JsonDiffer();
var myVar = new MyClass();
myVar.MyList= new List<string>() { "Value1", "Value2", "Value3", "Value4", "Value5" };
JToken original = JToken.Parse(myVar.ToJson());
//first let's remove a value from the list
myVar.MyList.Remove("Value2");
JToken modified1 = JToken.Parse(myVar.ToJson());
var diff1 = differ.Diff(original, modified1);
Assert.AreEqual(1, diff1.Operations.Count);//correct - 1 "remove" operation
//now add a value to the list
myVar.MyList.Add("Value6");
JToken modified2 = JToken.Parse(myVar.ToJson());
var diff2 = differ.Diff(modified1, modified2);
Assert.AreEqual(1, diff2.Operations.Count);//correct - 1 "add" operation
//now both remove a value and add a value
myVar.MyList.Remove("Value3");
myVar.MyList.Add("Value7");
JToken modified3 = JToken.Parse(myVar.ToJson());
var diff3 = differ.Diff(modified2, modified3);
//i would expect 2 operations, 1 remove and 1 add
Assert.AreEqual(2, diff3.Operations.Count);//FAILS - there are 7 operations: 3 remove, 1 replace and 3 add
}
}
`
Kind regards,
Sven.
Hi,
I have an issue when creating diffpatches on my objects after I have modified a sub-collection on those objects. It all works fine as long as I add or remove items to the collection, but not when I both and and remove items. I've create a very simple unit test that demonstrates this. Is this an issue or "expected behavior" ?
Test:
`
public class MyClass
{
public List MyList { get; set; }
}
`
Kind regards,
Sven.