示例#1
0
        public void CriarEmprestimoValido_DeveFuncionar()
        {
            IList <Livro> ListaLivros = new List <Livro>();

            ListaLivros.Add(LivroMock.Object);
            Emprestimo emprestimo = ObjectMother.ObterEmprestimoValido(ListaLivros);

            emprestimo.Validate();
            emprestimo.Id.Should().Be(1);
        }
        public void Emprestimo_AtualizarRepositorio_DeveFalhar()
        {
            IList <Livro> ListaLivros = _repositorioLivro.BuscarTodos();
            Emprestimo    Emprestimo  = ObjectMother.ObterEmprestimoValido(ListaLivros);

            Emprestimo.Id = 0;
            Action act = () => Emprestimo.Validate();

            act.Should().Throw <IdentifierUndefinedException>();
        }
示例#3
0
        public void CriarEmprestimoInvalidoQuantidadeMinimaLivros_DeveFalhar()
        {
            IList <Livro> ListaLivros = new List <Livro>();

            ListaLivros.Add(LivroMock.Object);
            Emprestimo emprestimo = ObjectMother.ObterEmprestimoValido(ListaLivros);

            emprestimo.Livros.Clear();
            Action act = () => emprestimo.Validate();

            act.Should().Throw <BookwitchMinimumException>();
        }
示例#4
0
 public void Deletar(Emprestimo entidade)
 {
     entidade.Validate();
     if (entidade.Livros.Count >= 1)
     {
         foreach (var item in entidade.Livros)
         {
             Db.Delete(SqlDeleteSecundaria, TakeSecundario(entidade, item));
         }
     }
     Db.Delete(SqlDelete, Take(entidade));
 }
 public void Deletar(Emprestimo entidade)
 {
     entidade.Validate();
     _repositorio.Deletar(entidade);
 }
 public Emprestimo Atualizar(Emprestimo entidade)
 {
     entidade.Validate();
     entidade = _repositorio.Atualizar(entidade);
     return(entidade);
 }
示例#7
0
 public Emprestimo Atualizar(Emprestimo entidade)
 {
     entidade.Validate();
     Db.Update(SqlUpdate, Take(entidade));
     return(entidade);
 }