Exemple #1
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);
        }
Exemple #2
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();
        }
Exemple #3
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));
        }