Пример #1
0
        public void Emprestimo_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();
            Action     validar    = () => emprestimo.Validar();

            validar.Should().NotThrow <BusinessException>();
        }
Пример #2
0
        public void EmprestimoRepository_Delete_ShouldBeFail()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();
            Action     delete     = () => _repository.Delete(emprestimo);

            delete.Should().Throw <IdentificadorIndefinidoException>();
        }
Пример #3
0
        public void EmprestimoIntegracao_Delete_ShouldBeFail()
        {
            //Executa
            Action comparison = () => _service.Deletar(ObjetoMaeEmprestimo.obterEmprestimo());

            //Saída
            comparison.Should().Throw <IdentificadorIndefinidoException>();
        }
Пример #4
0
        public void EmprestimoRepository_Update_ShouldBeFail()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 0;
            Action update = () => _repository.Atualizar(emprestimo);

            update.Should().Throw <IdentificadorIndefinidoException>();
        }
Пример #5
0
        public void EmprestimoRepository_Update_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;
            var emprestimoEditar = _repository.Atualizar(emprestimo);

            emprestimoEditar.Cliente.Should().Be(emprestimo.Cliente);
        }
Пример #6
0
        public void Emprestimo_Disponibilidade_ShouldBeFail()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Livro.Disponibilidade = false;
            Action validar = () => emprestimo.Validar();

            validar.Should().Throw <DisponibilidadeException>();
        }
Пример #7
0
        public void EmprestimoIntegracao_Adicionar_Titulo_ShouldBeFail()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Livro.Disponibilidade = false;

            Action comparison = () => _service.Salvar(emprestimo);

            comparison.Should().Throw <DisponibilidadeException>();
        }
Пример #8
0
        public void EmprestimoRespository_AddValidate_ShouldBeFail()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;
            emprestimo.Livro.Disponibilidade = false;
            Action salvar = () => _repository.Salvar(emprestimo);

            salvar.Should().Throw <DisponibilidadeException>();
        }
Пример #9
0
        public void EmprestimoRepository_Delete_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;

            _repository.Delete(emprestimo);
            Emprestimo deleteObject = _repository.Obter(2);

            deleteObject.Should().BeNull();
        }
Пример #10
0
        public void EmprestimoRespository_Add_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id       = 2;
            emprestimo.Livro.Id = 1;
            _repository.Salvar(emprestimo);
            var emprestimos = _repository.ObterTodos();

            emprestimos.Count().Should().BeGreaterThan(0);
        }
Пример #11
0
        public void EmprestimoIntegracao_Atualizar_Id_Invalido_ShouldBeFail()
        {
            //Cenário
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            //Executa
            Action comparison = () => _service.Atualizar(modelo);

            //Saída
            comparison.Should().Throw <IdentificadorIndefinidoException>();
        }
Пример #12
0
        public void EmprestimoService_Update_Invalid_Id_ShouldBeFail()
        {
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Id = 0;

            EmprestimoService service = new EmprestimoService(_mockRepository.Object);

            Action update = () => service.Atualizar(modelo);

            update.Should().Throw <IdentificadorIndefinidoException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Пример #13
0
        public void EmprestimoService_Add_ShouldBeFail()
        {
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Livro.Disponibilidade = false;

            EmprestimoService service = new EmprestimoService(_mockRepository.Object);

            Action comparison = () => service.Salvar(modelo);

            comparison.Should().Throw <DisponibilidadeException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Пример #14
0
        public void EmprestimoIntegracao_Atualizar_Titulo_ShouldBeFail()
        {
            //Cenário
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Id = 1;
            modelo.Livro.Disponibilidade = false;

            //Executa
            Action comparison = () => _service.Atualizar(modelo);

            //Saída
            comparison.Should().Throw <DisponibilidadeException>();
        }
Пример #15
0
        public void EmprestimoService_Get_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 3;

            _mockRepository.Setup(m => m.Obter(3)).Returns(emprestimo);

            EmprestimoService service   = new EmprestimoService(_mockRepository.Object);
            Emprestimo        resultado = service.Obter(3);

            resultado.Should().NotBeNull();
            _mockRepository.Verify(repository => repository.Obter(3));
        }
Пример #16
0
        public void EmprestimoIntegracao_Atualizar_ShouldBeOk()
        {
            //Cenário
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Id = 2;

            //Executa
            Emprestimo emprestimo = _service.Atualizar(modelo);

            //Saída
            emprestimo.Should().NotBeNull();
            emprestimo.Id.Should().Be(modelo.Id);
            emprestimo.Cliente.Should().Be(modelo.Cliente);
        }
Пример #17
0
        public void EmprestimoService_Delete_ShouldBeOk()
        {
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Id = 1;

            _mockRepository.Setup(m => m.Delete(modelo));


            EmprestimoService service = new EmprestimoService(_mockRepository.Object);

            service.Deletar(modelo);

            _mockRepository.Verify(repository => repository.Delete(modelo));
        }
Пример #18
0
        public void EmprestimoService_Add_ShouldBeOK()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            _mockRepository.Setup(m => m.Salvar(emprestimo)).Returns(new Emprestimo()
            {
                Id = 1
            });
            EmprestimoService service = new EmprestimoService(_mockRepository.Object);

            Emprestimo resultado = service.Salvar(emprestimo);

            resultado.Should().NotBeNull();
            resultado.Id.Should().BeGreaterThan(0);
            _mockRepository.Verify(repository => repository.Salvar(emprestimo));
        }
Пример #19
0
        public void EmprestimoService_Update_ShouldBeOK()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;

            _mockRepository.Setup(m => m.Atualizar(emprestimo)).Returns(emprestimo);

            EmprestimoService service = new EmprestimoService(_mockRepository.Object);


            Emprestimo resultado = service.Atualizar(emprestimo);

            resultado.Should().NotBeNull();
            resultado.Cliente.Should().Be("João");
            _mockRepository.Verify(repository => repository.Atualizar(emprestimo));
        }
Пример #20
0
        public void EmprestimoIntegracao_Delete_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;
            //Executa
            _service.Deletar(emprestimo);

            //Saída
            Emprestimo emprestimodel = _service.Obter(2);

            emprestimodel.Should().BeNull();

            List <Emprestimo> posts = _service.ObterTodos() as List <Emprestimo>;

            posts.Count().Should().Be(1);
        }
Пример #21
0
        public void EmprestimoIntegracao_Adicionar_ShouldBeOk()
        {
            //Executa
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Livro.Id = 1;
            Emprestimo emprestimoAdd = _service.Salvar(emprestimo);

            //Saída
            emprestimo.Id.Should().BeGreaterThan(0);

            var last = _service.Obter(emprestimo.Id);

            last.Should().NotBeNull();

            var posts = _service.ObterTodos();

            posts.Count().Should().BeGreaterThan(0);
        }