public void EmptyBothAddedTheSame() { var left = DiffFactory.Create <HashSet <int> >().Unordered() .Added(3) .MakeDiff(); var right = DiffFactory.Create <HashSet <int> >().Unordered() .Added(3) .MakeDiff(); IConflictContainer conflicts; var result = Merger.Instance.Partial.MergeDiffs(left, right, out conflicts); var merged = DiffFactory.Create <HashSet <int> >().Unordered() .Added(3) .MakeDiff(); Assert.AreEqual(merged, result); Assert.IsFalse(conflicts.HasConflicts); }
public void DictionaryOneAdded() { var @base = new Dictionary <string, int[]> { { "a", new[] { 1, 2 } } }; var changed = new Dictionary <string, int[]> { { "a", new[] { 1, 2, 3 } } }; var expected = DiffFactory.Create <Dictionary <string, int[]> >().KeyValue() .Changed("a", inner => inner.Ordered() .Added(2, 3) ) .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void ClassOneAdded() { var @base = new Sample { Value = new[] { 1, 2 } }; var changed = new Sample { Value = new[] { 1, 2, 3 } }; var expected = DiffFactory.Create <Sample>().Class() .Changed(x => x.Value, inner => inner.Ordered() .Added(2, 3) ) .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void TestNoneDifferent() { var @base = new Sample { Value = "one", Value2 = "one2" }; var changed = new Sample { Value = "one", Value2 = "one2" }; var expected = DiffFactory.Create <Sample>().Class() .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void TestNullLeft() { var @base = new Sample { Value = "one", Value2 = null }; var changed = new Sample { Value = "one", Value2 = "one2" }; var expected = DiffFactory.Create <Sample>().Class() .Replaced(x => x.Value2, null, "one2") .MakeDiff(); var ret = Merger.Instance.Partial.Diff(@base, changed); Assert.AreEqual(expected, ret); }
public void EmptyReplacedReplaced() { var left = DiffFactory.Create <HashSet <int> >().Unordered() .Replaced(3, 4) .MakeDiff(); var right = DiffFactory.Create <HashSet <int> >().Unordered() .Replaced(3, 5) .MakeDiff(); IConflictContainer conflicts; var result = Merger.Instance.Partial.MergeDiffs(left, right, out conflicts); var merged = DiffFactory.Create <HashSet <int> >().Unordered() .Conflicted( c => c.Replaced(3, 4), c => c.Replaced(3, 5) ) .MakeDiff(); Assert.AreEqual(merged, result); Assert.IsTrue(conflicts.HasConflicts); }
public void LeftAdded() { var left = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .Added("a", new Sample { Id = 1 }) .MakeDiff(); var right = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .MakeDiff(); IConflictContainer conflicts; var result = Merger.Instance.Partial.MergeDiffs(left, right, out conflicts); var merged = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .Added("a", new Sample { Id = 1 }) .MakeDiff(); Assert.AreEqual(merged, result); Assert.IsFalse(conflicts.HasConflicts); }
public void BothChanged() { var left = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .Changed("a", inner => inner.Class() .Replaced(x => x.Value, "a", "b") ) .MakeDiff(); var right = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .Changed("a", inner => inner.Class()) .MakeDiff(); IConflictContainer conflicts; var result = Merger.Instance.Partial.MergeDiffs(left, right, out conflicts); var merged = DiffFactory.Create <Dictionary <string, Sample> >().KeyValue() .Changed("a", inner => inner.Class() .Replaced(x => x.Value, "a", "b") ) .MakeDiff(); Assert.AreEqual(merged, result); Assert.IsFalse(conflicts.HasConflicts); }