Example #1
0
        public async Task Should_add_file_to_repositoryAsync()
        {
            var handler = new PushLeftJsonCommandHandler(_repository.Object);

            _repository.Setup(r => r.GetById(It.Is <string>(i => i == _id))).Returns <DiffJson>(null);
            await handler.Handle(new PushLeftJsonCommand(_id, _json), default(CancellationToken));

            _repository.Verify(_add, Times.Once);
        }
Example #2
0
        public async Task Should_add_file_to_existend_idAsync()
        {
            var existemDiff = new DiffJson(_id)
            {
                Left = null
            };

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

            _repository.Verify(_update, Times.Once);
            Assert.Equal(_json, existemDiff.Left);
        }
Example #3
0
        public async Task Shouldnt_add_file_to_existend_filled_left_diffAsync()
        {
            var leftOldContent = "alreadyfilled";
            var existemDiff    = new DiffJson(_id)
            {
                Left = leftOldContent
            };

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

            _repository.Verify(_update, Times.Never);
            _repository.Verify(_add, Times.Never);
            Assert.Equal(leftOldContent, existemDiff.Left);
        }