Exemplo n.º 1
0
        public void Should_return_that_the_jsons_are_different()
        {
            var diffJason = new DiffJson(_id)
            {
                Left = "{\"key\":\"value\"}", Right = "{\"key\":\"test\"}"
            };
            var differResult = diffJason.Diff();

            Assert.False(differResult.AreEqual);
        }
Exemplo n.º 2
0
        public void Should_clone_before_adding_diff()
        {
            var id      = "teste";
            var newDiff = new DiffJson(id);

            _repository.Add(newDiff);
            var clonedDiff = _list.First(d => d.Id == id);

            Assert.Equal(newDiff, clonedDiff);
            Assert.False(newDiff == clonedDiff);
        }
Exemplo n.º 3
0
        public void Should_add_diff_and_get_clone()
        {
            var id      = "teste";
            var newDiff = new DiffJson(id);

            _list.Add(newDiff);
            var clonedDiff = _repository.GetById(id);

            Assert.Equal(newDiff, clonedDiff);
            Assert.False(newDiff == clonedDiff);
        }
Exemplo n.º 4
0
        public void Should_return_that_the_jsons_they_are_equal()
        {
            var json      = "{\"some\":\"json\"}";
            var diffJason = new DiffJson(_id)
            {
                Left = json, Right = json
            };
            var differResult = diffJason.Diff();

            Assert.True(differResult.AreEqual);
            Assert.Equal(_id, differResult.Id);
        }
Exemplo n.º 5
0
        public void Should_return_that_the_jsons_they_are_different_and_where_they_are()
        {
            var offset    = 8;
            var length    = 5;
            var diffJason = new DiffJson(_id)
            {
                Left = "{\"key\":\"value\"}", Right = "{\"key\":\"tests\"}"
            };
            var differResult = diffJason.Diff();

            Assert.False(differResult.AreEqual);
            Assert.Contains(differResult.DiffResults, r => r.Offset == offset && r.Length == length);
        }
Exemplo n.º 6
0
        public async Task Should_add_file_to_existend_idAsync()
        {
            var existemDiff = new DiffJson(_id)
            {
                Right = null
            };

            _repository.Setup(r => r.GetById(It.Is <string>(i => i == _id))).Returns(existemDiff);
            var handler = new PushRightJsonCommandHandler(_repository.Object);
            await handler.Handle(new PushRightJsonCommand(_id, _json), default(CancellationToken));

            _repository.Verify(_update, Times.Once);
            Assert.Equal(_json, existemDiff.Right);
        }
Exemplo n.º 7
0
        public void Should_update_sides_diff()
        {
            var id      = "teste";
            var json    = "json";
            var newDiff = new DiffJson(id);

            _list.Add(newDiff);
            var updateDiff = new DiffJson(id)
            {
                Left = json + "L", Right = json + "R"
            };

            _repository.Update(updateDiff);
            Assert.Equal(newDiff, updateDiff);
        }
Exemplo n.º 8
0
        public async Task Shouldnt_add_file_to_existend_filled_right_diffAsync()
        {
            var rightOldContent = "alreadyfilled";
            var existemDiff     = new DiffJson(_id)
            {
                Right = rightOldContent
            };

            _repository.Setup(r => r.GetById(It.Is <string>(i => i == _id))).Returns(existemDiff);
            var handler = new PushRightJsonCommandHandler(_repository.Object);
            await handler.Handle(new PushRightJsonCommand(_id, _json), default(CancellationToken));

            _repository.Verify(_update, Times.Never);
            _repository.Verify(_add, Times.Never);
            Assert.Equal(rightOldContent, existemDiff.Right);
        }
Exemplo n.º 9
0
        public void Should_clone_null_DiffJson()
        {
            DiffJson json = null;

            Assert.Null(json.Clone());
        }