public void Integration_AddEmprestimo_ShouldBeOK() { _emprestimo = ObjectMother.GetEmprestimo(); _service.Adicionar(_emprestimo); var livroVerify = _service.Get(_emprestimo.Id); livroVerify.Should().NotBeNull(); livroVerify.Id.Should().Be(_emprestimo.Id); }
public void Service_Emprestimo_Deveria_Adicionar_Emprestimo() { _emprestimo = ObjectMother.GetEmprestimo(); _repository .Setup(l => l.Adicionar(It.IsAny <Emprestimo>())) .Returns(new Emprestimo { Cliente = _emprestimo.Cliente, DataDevolucao = _emprestimo.DataDevolucao, Id = 1 }); _service.Adicionar(_emprestimo); _repository.Verify(l => l.Adicionar(_emprestimo)); }
public void EmprestimoService_Adicionar_NomeClienteNulo_ShouldBeFail() { Emprestimo modelo = ObjectMotherEmprestimo.GetEmprestimoInvalidoClienteNome(); EmprestimoService service = new EmprestimoService(_mockRepositorio.Object); Action comparison = () => service.Adicionar(modelo); comparison.Should().Throw <ExcecaoNomeClienteNulo>(); _mockRepositorio.VerifyNoOtherCalls(); }
public void Emprestimo_IntegracaoSistema_DeveFuncionar() { Livro livro = ObjectMother.ObterLivroValido(); IList <Livro> ListaLivros = new List <Livro>(); ListaLivros.Add(livro); Emprestimo Emprestimo = ObjectMother.ObterEmprestimoValido(ListaLivros); Emprestimo result = _emprestimoService.Adicionar(Emprestimo); result.Id.Should().BeGreaterThan(0); IList <Emprestimo> emprestimoList = _emprestimoService.BuscarTodos(); }
public void EmprestimoService_Adicionar_ShouldBeOK() { Emprestimo modelo = ObjectMotherEmprestimo.GetEmprestimo(); modelo.Livro = _livro; _mockRepositorio.Setup(m => m.Salvar(modelo)).Returns(new Emprestimo() { Id = 1 }); EmprestimoService service = new EmprestimoService(_mockRepositorio.Object); Emprestimo resultado = service.Adicionar(modelo); resultado.Should().NotBeNull(); resultado.Id.Should().BeGreaterThan(0); _mockRepositorio.Verify(repositorio => repositorio.Salvar(modelo)); }
public void EmprestimoService_CriarRepositorio_DeveFuncionar() { Livro livro = ObjectMother.ObterLivroValido(); IList <Livro> ListaLivros = new List <Livro>(); ListaLivros.Add(livro); Emprestimo Emprestimo = ObjectMother.ObterEmprestimoValido(ListaLivros); Emprestimo.Id = 0; mockRepositorio.Setup(m => m.Adicionar(Emprestimo)).Returns(new Emprestimo { Id = 1 }); Emprestimo result = emprestimoService.Adicionar(Emprestimo); result.Id.Should().BeGreaterThan(0); mockRepositorio.Verify(m => m.Adicionar(Emprestimo)); }