Beispiel #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);
        }
Beispiel #2
0
        public void EmprestimoService_Exclui_DeveSerValido()
        {
            //Cenário
            Livro livro = new Livro();

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

            emprestimo.Id = 1;

            _mockEmprestimoRepositorio.Setup(rp => rp.Excluir(emprestimo));

            //Ação
            _emprestimoService.Exclui(emprestimo);

            //Verificar
            _mockEmprestimoRepositorio.Verify(rp => rp.Excluir(emprestimo));
        }