コード例 #1
0
        public void Service_Cliente_Delete_DeveJogarExcessao_NotFoundException()
        {
            //Arrange
            var clienteCmd = ClienteObjectMother.GetClienteValidoParaDeletar();

            _repositoryFake.Setup(x => x.Delete(clienteCmd.Id)).Throws <NotFoundException>();
            //Action
            Action act = () => _service.Delete(clienteCmd);

            //Assert
            act.Should().Throw <NotFoundException>();
            _repositoryFake.Verify(pr => pr.Delete(clienteCmd.Id), Times.Once);
        }
コード例 #2
0
        public void Service_Cliente_Delete_DevePassar()
        {
            //Arrange
            var clienteCmd = ClienteObjectMother.GetClienteValidoParaDeletar();
            var removido   = true;

            _repositoryFake.Setup(pr => pr.Delete(clienteCmd.Id)).Returns(removido);
            //Action
            var clienteRemovido = _service.Delete(clienteCmd);

            //Assert
            _repositoryFake.Verify(pr => pr.Delete(clienteCmd.Id), Times.Once);
            clienteRemovido.Should().BeTrue();
        }
コード例 #3
0
        public void Controller_Clientes_Delete_DevePassar()
        {
            // Arrange
            var cliente   = ClienteObjectMother.GetClienteValidoParaDeletar();
            var isRemoved = true;

            _clienteServiceMock.Setup(c => c.Delete(cliente)).Returns(isRemoved);
            // Action
            IHttpActionResult callback = _clientesController.Delete(cliente);
            // Assert
            var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject;

            _clienteServiceMock.Verify(s => s.Delete(cliente), Times.Once);
            httpResponse.Content.Should().BeTrue();
        }