コード例 #1
0
        public void Should_return_error_when_command_is_invalid()
        {
            var command = new DeleteCommerceCommand();

            var handler = new DeleteCommerceHandler(_commerceRepositoryMock.Object);

            var result = handler.Handle(command);

            Assert.False(result.Success);
            Assert.Equal("Não foi possível remover o comércio.", result.Message);
            Assert.Contains(handler.Notifications, x => x.Property == "Id");
        }
コード例 #2
0
        public void Should_return_not_found_when_commerce_is_not_found()
        {
            _commerceRepositoryMock.Setup(x => x.GetById(It.IsAny <Guid>()))
            .Returns(() => null);

            var command = new DeleteCommerceCommand()
            {
                Id = Guid.NewGuid()
            };

            var handler = new DeleteCommerceHandler(_commerceRepositoryMock.Object);

            var result = handler.Handle(command);

            Assert.False(result.Success, result.Message);
            Assert.Equal("Não foi possível encontrar o comércio.", result.Message);
        }
コード例 #3
0
        public void Should_return_success()
        {
            var commerceMock = new Mock <Commerce>(string.Empty, new Mock <Site>().Object, new Mock <Address>().Object);

            _commerceRepositoryMock.Setup(x => x.GetById(It.IsAny <Guid>()))
            .Returns(commerceMock.Object);

            var command = new DeleteCommerceCommand()
            {
                Id = Guid.NewGuid()
            };

            var handler = new DeleteCommerceHandler(_commerceRepositoryMock.Object);

            var result = handler.Handle(command);

            Assert.True(result.Success);
        }