Esempio n. 1
0
        public void Merge_WithoutConflicts_Merges(JToken update, JToken conflict, JToken parent, JToken expected)
        {
            IJsonMergeVisitor service = new JsonMergeVisitor();

            IMergeResult result = service.Merge(update, conflict, parent);

            Assert.That(result, ObjectHas.Property <MergeResult>(x => x.HasConflicts).EqualTo(false)
                        & ObjectHas.Property <MergeResult>(x => x.Merged).Matches(JsonIs.EqualTo(expected)));
        }
Esempio n. 2
0
        public void Merge_WithConflicts_FailsMerge(JToken update, JToken conflict, JToken parent, JToken expected)
        {
            IJsonMergeVisitor service = new JsonMergeVisitor();

            IMergeResult result = service.Merge(update, conflict, parent);

            Assert.That(result, ObjectHas.Property <MergeResult>(x => x.HasConflicts).EqualTo(true));
            Assert.That(result.Conflicts, JsonIs.EqualTo(expected));
        }
Esempio n. 3
0
        public void Merge_TypeMismatchArray_IsConflicted()
        {
            JToken update   = Json("{ arr: [1,2,3] }");
            JToken conflict = Json("{ arr: [2,3,1] }");
            JToken origin   = Json("{ arr: 'foo' }");
            JToken diff     = Json("{ arr: { origin: 'foo', other: [2,3,1], update: [1,2,3] } }");

            IJsonMergeVisitor visitor = new JsonMergeVisitor();

            IMergeResult result = visitor.Merge(update, conflict, origin);

            Assert.That(result, ObjectHas.Property <MergeResult>(x => x.HasConflicts).True
                        & ObjectHas.Property <MergeResult>(x => x.Conflicts).Matches(JsonIs.EqualTo(diff)));
        }