Exemplo n.º 1
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));
        }
Exemplo n.º 2
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)));
        }
Exemplo 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)));
        }
Exemplo n.º 4
0
        public void Merge_ScrambledIntArray_IsConflicted()
        {
            JToken update   = Json("{ arr: [1,2,3] }");
            JToken conflict = Json("{ arr: [2,3,1] }");
            JToken origin   = Json("{ arr: [3,1,2] }");
            JToken diff     = Json("{ arr: { origin: [3,1,2], 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).EqualTo(diff));
        }