コード例 #1
0
        public void Get_Deveria_Retornar_Um_Emprestimo()
        {
            //Arrange
            Emprestimo resultEmprestimo = _emprestimoRepository.Save(_emprestimoDefault);

            //Action
            Emprestimo resultGet = _emprestimoRepository.Get(resultEmprestimo.Id);

            //Assert
            resultGet.Should().NotBeNull();
            resultGet.Id.Should().Be(resultEmprestimo.Id);
            resultGet.Should().Equals(resultEmprestimo);
        }
コード例 #2
0
        public void Sistema_Deveria_Buscar_Um_Emprestimo_Pelo_Id()
        {
            //Arrange
            Emprestimo resultEmprestimo = _emprestimoService.Add(_emprestimoDefault);

            //Action
            Emprestimo resultGet = _emprestimoService.Get(resultEmprestimo.Id);

            //Assert
            resultGet.Should().NotBeNull();
            resultGet.Id.Should().Be(resultEmprestimo.Id);
            resultGet.Should().Equals(resultEmprestimo);
        }
コード例 #3
0
        public void Sistema_Deveria_Salvar_Um_Novo_Emprestimo_E_Retornar_Do_Banco()
        {
            //Action-Arrange
            Emprestimo resultEmprestimo = _emprestimoService.Add(_emprestimoDefault);

            //Assert
            resultEmprestimo.Should().NotBeNull();
            resultEmprestimo.Id.Should().NotBe(0);

            Emprestimo resultGet = _emprestimoService.Get(resultEmprestimo.Id);

            resultGet.Should().NotBeNull();
            resultGet.Should().Equals(resultEmprestimo);
        }
コード例 #4
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);
        }
コード例 #5
0
        public void Repository_Emprestimo_Sql_Excluir_ShouldBeOk()
        {
            _emprestimo = ObjectMother.GetEmprestimoComId();
            _repository.Excluir(_emprestimo.Id);
            Emprestimo recebe = _repository.GetById(_emprestimo.Id);

            recebe.Should().BeNull();
        }
コード例 #6
0
        public void EmprestimoIntegracaoSistema_Obter_DeveRetornarExcecao()
        {
            //Ação
            Emprestimo emprestimoResultado = _emprestimoService.Obtem(999999999);

            //Verificar
            emprestimoResultado.Should().BeNull();
        }
コード例 #7
0
        public void EmprestimoRepositorio_Get_ShouldBeOk()
        {
            int        idSearch = 1;
            Emprestimo result   = _service.Get(idSearch);

            result.Should().NotBeNull();
            result.Id.Should().Be(idSearch);
        }
コード例 #8
0
        public void Integration_DeleteEmprestimo_ShouldBeOK()
        {
            _emprestimo = ObjectMother.GetEmprestimoComId();
            _service.Excluir(_emprestimo);
            Emprestimo received = _service.Get(_emprestimo.Id);

            received.Should().BeNull();
        }
コード例 #9
0
        public void EmprestimoIntegracao_Obter_ShouldBeFail()
        {
            //Executa
            Emprestimo emprestimo = _service.Obter(3);

            //Saída
            emprestimo.Should().BeNull();
        }
コード例 #10
0
        public void DeveInstaciarEmprestimoValido()
        {
            var emprestimo = new Emprestimo(amigo, jogo);

            emprestimo.Should().NotBeNull();
            emprestimo.Valid.Should().BeTrue();
            emprestimo.Jogo.Nome.Should().Be(jogo.Nome);
            emprestimo.Amigo.Apelido.Should().Be(amigo.Apelido);
            emprestimo.DataEmprestimo.Date.Should().Be(DateTime.Now.Date);
        }
コード例 #11
0
        public void DeveInstaciarEmprestimoInvalidoComJogoNulo()
        {
            var emprestimo = new Emprestimo(amigo, null);

            emprestimo.Should().NotBeNull();
            emprestimo.Valid.Should().BeFalse();
            emprestimo.Jogo.Should().Be(null);
            emprestimo.Amigo.Apelido.Should().Be(amigo.Apelido);
            emprestimo.DataEmprestimo.Date.Should().Be(DateTime.Now.Date);
        }
コード例 #12
0
        public void EmprestimoRepositorio_Get_ShouldBeOk()
        {
            int        biggerThan = 0;
            int        idSearch   = 1;
            Emprestimo result     = _repositorio.Get(idSearch);

            result.Should().NotBeNull();
            result.Id.Should().Be(idSearch);
            result.Id.Should().BeGreaterThan(biggerThan);
        }
コード例 #13
0
        public void EmprestimoRepositorio_Delete_ShouldBeOk()
        {
            int        idSearch   = 1;
            Emprestimo emprestimo = _repositorio.Get(idSearch);

            _repositorio.Delete(emprestimo);
            Emprestimo result = _repositorio.Get(idSearch);

            result.Should().BeNull();
        }
コード例 #14
0
        public void EmprestimoRepository_Delete_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 2;

            _repository.Delete(emprestimo);
            Emprestimo deleteObject = _repository.Obter(2);

            deleteObject.Should().BeNull();
        }
コード例 #15
0
        public void EmprestimoRepositorio_Delete_ShouldBeOk()
        {
            int        idSearch   = 1;
            Emprestimo emprestimo = _service.Get(idSearch);

            emprestimo.Livro.Disponibilidade = true;
            _service.Delete(emprestimo);
            Emprestimo result = _service.Get(idSearch);

            result.Should().BeNull();
        }
コード例 #16
0
        public void Emprestimo_DeletarRepositorio_DeveFuncionar()
        {
            IList <Livro> ListaLivros = _repositorioLivro.BuscarTodos();
            Emprestimo    Emprestimo  = ObjectMother.ObterEmprestimoValido(ListaLivros);

            _repositorio.Deletar(Emprestimo);

            Emprestimo Result = _repositorio.BuscarPorId(Emprestimo.Id);

            Result.Should().BeNull();
        }
コード例 #17
0
        public void DadoUmEmprestimoValidoDeveDisponiblizarOJogoParaEmprestimo()
        {
            var emprestimo = new Emprestimo(amigo, jogo);

            emprestimo.Should().NotBeNull();
            emprestimo.Valid.Should().BeTrue();

            emprestimo.Devolver();

            emprestimo.DataDevolucao.HasValue.Should().BeTrue();
        }
コード例 #18
0
        public void Save_Deveria_Gravar_Um_Novo_Emprestimo()
        {
            //Action-Arrange
            Emprestimo resultEmprestimo = _emprestimoRepository.Save(_emprestimoDefault);

            //Assert
            Emprestimo resultGet = _emprestimoRepository.Get(resultEmprestimo.Id);

            resultEmprestimo.Should().NotBeNull();
            resultGet.Should().NotBeNull();
            resultGet.Id.Should().Be(resultEmprestimo.Id);
        }
コード例 #19
0
        public void EmprestimoIntegracao_Obter_ShouldBeOk()
        {
            //Executa
            Emprestimo post = _service.Obter(1);

            //Saída
            post.Should().NotBeNull();

            List <Emprestimo> posts = (List <Emprestimo>)_service.ObterTodos();
            var found = posts.Find(x => x.Id == post.Id);

            post.Id.Should().Be(found.Id);
        }
コード例 #20
0
        public void EmprestimoService_Get_ShouldBeOk()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            emprestimo.Id = 3;

            _mockRepository.Setup(m => m.Obter(3)).Returns(emprestimo);

            EmprestimoService service   = new EmprestimoService(_mockRepository.Object);
            Emprestimo        resultado = service.Obter(3);

            resultado.Should().NotBeNull();
            _mockRepository.Verify(repository => repository.Obter(3));
        }
コード例 #21
0
        public void EmprestimoService_Get_ShouldBeOk()
        {
            _mockRepositorio.Setup(m => m.Get(1)).Returns(new Emprestimo()
            {
                Id            = 1,
                NomeCliente   = "Cliente Nome",
                DataDevolucao = DateTime.Now.AddDays(10)
            });
            EmprestimoService service   = new EmprestimoService(_mockRepositorio.Object);
            Emprestimo        resultado = service.Get(1);

            resultado.Should().NotBeNull();
            _mockRepositorio.Verify(repositorio => repositorio.Get(1));
        }
コード例 #22
0
        public void Sistema_Deveria_Deletar_Um_Emprestimo_Pelo_Id()
        {
            Emprestimo resultEmprestimo = _emprestimoService.Add(_emprestimoDefault);

            //Action
            _emprestimoService.Delete(resultEmprestimo);

            //Assert
            Emprestimo         resultGet    = _emprestimoService.Get(resultEmprestimo.Id);
            IList <Emprestimo> resultGetAll = _emprestimoService.GetAll();

            resultGet.Should().BeNull();
            resultGetAll.Should().HaveCount(1);
        }
コード例 #23
0
        public void Emprestimo_ObterPorIdIntegracaoSistema_DeveFuncionar()
        {
            Livro         livro       = ObjectMother.ObterLivroValido();
            IList <Livro> ListaLivros = new List <Livro>();

            ListaLivros.Add(livro);
            Emprestimo Emprestimo = ObjectMother.ObterEmprestimoValido(ListaLivros);

            Emprestimo emprestimoGetById = _emprestimoService.BuscarPorId(Emprestimo.Id);

            emprestimoGetById.Should().NotBeNull();

            emprestimoGetById.Id.Should().Be(Emprestimo.Id);
        }
コード例 #24
0
        public void Delete_Deveria_Deletar_Um_Emprestimo()
        {
            //Arrange
            Emprestimo resultEmprestimo = _emprestimoRepository.Save(_emprestimoDefault);

            //Action
            _emprestimoRepository.Delete(resultEmprestimo);

            //Assert
            Emprestimo         resultGet    = _emprestimoRepository.Get(resultEmprestimo.Id);
            IList <Emprestimo> resultGetAll = _emprestimoRepository.GetAll();

            resultGet.Should().BeNull();
            resultGetAll.Should().HaveCount(1);
        }
コード例 #25
0
        public void EmprestimoIntegracao_Atualizar_ShouldBeOk()
        {
            //Cenário
            Emprestimo modelo = ObjetoMaeEmprestimo.obterEmprestimo();

            modelo.Id = 2;

            //Executa
            Emprestimo emprestimo = _service.Atualizar(modelo);

            //Saída
            emprestimo.Should().NotBeNull();
            emprestimo.Id.Should().Be(modelo.Id);
            emprestimo.Cliente.Should().Be(modelo.Cliente);
        }
コード例 #26
0
        public void EmprestimoService_Add_ShouldBeOK()
        {
            Emprestimo emprestimo = ObjetoMaeEmprestimo.obterEmprestimo();

            _mockRepository.Setup(m => m.Salvar(emprestimo)).Returns(new Emprestimo()
            {
                Id = 1
            });
            EmprestimoService service = new EmprestimoService(_mockRepository.Object);

            Emprestimo resultado = service.Salvar(emprestimo);

            resultado.Should().NotBeNull();
            resultado.Id.Should().BeGreaterThan(0);
            _mockRepository.Verify(repository => repository.Salvar(emprestimo));
        }
コード例 #27
0
        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));
        }
コード例 #28
0
        public void EmprestimoService_Editar_ShouldBeOk()
        {
            Emprestimo modelo = ObjectMotherEmprestimo.GetEmprestimo();

            modelo.Id    = 1;
            modelo.Livro = _livro;
            _mockRepositorio.Setup(m => m.Editar(modelo)).Returns(new Emprestimo()
            {
                Id = 1, NomeCliente = "Nome do Cliente"
            });
            EmprestimoService service   = new EmprestimoService(_mockRepositorio.Object);
            Emprestimo        resultado = service.Editar(modelo);

            resultado.Should().NotBeNull();
            _mockRepositorio.Verify(repositorio => repositorio.Editar(modelo));
        }
コード例 #29
0
        public void Update_Deveria_Alterar_Os_Dados_De_Emprestimo()
        {
            //Arrange
            Emprestimo emprestimoResult = _emprestimoRepository.Save(_emprestimoDefault);

            emprestimoResult.Cliente = "Nome de Teste";

            //Action
            _emprestimoRepository.Update(emprestimoResult);

            //Assert
            Emprestimo resultGet = _emprestimoRepository.Get(emprestimoResult.Id);

            resultGet.Should().NotBeNull();
            resultGet.Id.Should().Be(emprestimoResult.Id);
            resultGet.Cliente.Should().Be("Nome de Teste");
        }
コード例 #30
0
        public void Sistema_Deveria_Alterar_Um_Emprestimo_Pelo_Id()
        {
            //Arrange
            Emprestimo resultEmprestimo = _emprestimoService.Add(_emprestimoDefault);

            resultEmprestimo.Cliente = "Cliente Atualizado";

            //Action
            _emprestimoService.Update(resultEmprestimo);

            //Assert
            Emprestimo resultGet = _emprestimoService.Get(resultEmprestimo.Id);

            resultGet.Should().NotBeNull();
            resultGet.Id.Should().Be(resultEmprestimo.Id);
            resultGet.Cliente.Should().Be("Cliente Atualizado");
        }