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); }
public void EmprestimoService_Obtem_DeveSerValido() { //Cenário Livro livro = new Livro(); livro.Id = 1; Emprestimo emprestimo = ObjectMother.ObterEmprestimoValido(); livro.Id = 1; _mockEmprestimoRepositorio.Setup(rp => rp.Obter(emprestimo.Id)).Returns(new Emprestimo { Id = 1, NomeCliente = "nome cliente", DataDevolucao = DateTime.Now.AddDays(2), Livro = livro }); //Ação Emprestimo retorno = _emprestimoService.Obtem(emprestimo.Id); //Verificar _mockEmprestimoRepositorio.Verify(rp => rp.Obter(emprestimo.Id)); retorno.Should().NotBeNull(); retorno.Id.Should().BeGreaterThan(0); }