-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
Say I have a 3 stages. First I have the initial value 1, then I change to 2 and then to 3 creating 2 diffs from 1 to 2 and from 2 to 3.
1->2->3.
Then I try to unpatch from 2 to 1 (2->1)
But because the value is current at 3 I'd expect it to stay at 3 and not revert to 1, but that's what happens here.
I have a small testcase here:
var jdp = new JsonDiffPatch();
var stage1 = JToken.Parse(@"{""stage"":1}");
var stage2 = JToken.Parse(@"{""stage"":2}");
var stage3 = JToken.Parse(@"{""stage"":3}");
var diff = jdp.Diff(stage1, stage2);
// Try to unpatch with stage2
var unpatched_stage2 = jdp.Unpatch(stage2, diff);
Assert.AreEqual(stage1.ToString(), unpatched_stage2.ToString());
// Try to unpatch with stage3 - this should not work as the original value is not stage2
var unpatched_stage3 = jdp.Unpatch(stage3, diff);
Assert.AreNotEqual(stage1.ToString(), unpatched_stage3.ToString());Metadata
Metadata
Assignees
Labels
No labels