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

            _repository.Setup(r => r.GetById(It.Is <string>(i => i == _id))).Returns <DiffJson>(null);
            await handler.Handle(new PushRightJsonCommand(_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)
            {
                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);
        }
Example #3
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);
        }