Example #1
0
        public void EmprestimoIntegracaoSistema_Adicionar_DeveSerValido()
        {
            //Cenário
            Livro livro = new Livro();

            livro.Id = 1;
            livro.Disponibilidade = true;
            Emprestimo emprestimo = ObjectMother.ObterEmprestimoValido();

            emprestimo.Id    = 0;
            emprestimo.Livro = livro;

            //Ação
            Emprestimo emprestimoResultado = _emprestimoService.Adiciona(emprestimo);

            //Verificar
            emprestimoResultado.Should().NotBeNull();
            emprestimoResultado.Id.Should().BeGreaterThan(0);
            emprestimoResultado.NomeCliente.Should().Be(emprestimo.NomeCliente);
            emprestimoResultado.Livro.Should().Be(emprestimo.Livro);
            emprestimoResultado.DataDevolucao.Should().BeBefore(DateTime.Now.AddDays(2));

            Emprestimo emprestimoGet = _emprestimoService.Obtem(emprestimoResultado.Id);

            emprestimoResultado.Id.Should().Be(emprestimoGet.Id);

            _emprestimoService.Exclui(emprestimoResultado);
        }
Example #2
0
        public void EmprestimoService_Adiciona_DeveSerValido()
        {
            //Cenário
            Livro livro = new Livro();

            livro.Id = 1;
            Emprestimo emprestimo = ObjectMother.ObterEmprestimoValido();

            emprestimo.Id    = 0;
            emprestimo.Livro = livro;
            emprestimo.Livro.Disponibilidade = true;

            //Ação
            _mockEmprestimoRepositorio.Setup(rp => rp.Adicionar(emprestimo)).Returns(new Emprestimo {
                Id = 1, NomeCliente = "nome", DataDevolucao = DateTime.Now.AddDays(2), Livro = livro
            });
            Emprestimo retorno = _emprestimoService.Adiciona(emprestimo);

            //Verificar
            _mockEmprestimoRepositorio.Verify(rp => rp.Adicionar(emprestimo));
            retorno.Should().NotBeNull();
            retorno.Id.Should().BeGreaterThan(0);
            retorno.Id.Should().NotBe(emprestimo.Id);
        }