예제 #1
0
        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 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);
        }
예제 #3
0
 public void Service_Emprestimo_Deveria_BuscarPorId()
 {
     _emprestimo = ObjectMother.GetEmprestimoComId();
     _repository
     .Setup(l => l.GetById(It.IsAny <int>()));
     _service.Get(_emprestimo.Id);
     _repository.Verify(l => l.GetById(_emprestimo.Id));
 }
        public void EmprestimoService_Get_IdInvalido_ShouldBeFail()
        {
            EmprestimoService service    = new EmprestimoService(_mockRepositorio.Object);
            Action            comparison = () => service.Get(0);

            comparison.Should().Throw <ExcecaoIdentifivadorIndefinido>();
            _mockRepositorio.VerifyNoOtherCalls();
        }
예제 #5
0
        public void Get_Deveria_Retornar_Um_Emprestimo()
        {
            //Arrange
            _emprestimoRepositoryMockObject.Setup(p => p.Get(It.IsAny <long>())).Returns(_emprestimoDefaultWithId);

            //Action
            Emprestimo retornoEmprestimo = _emprestimoService.Get(_emprestimoDefaultWithId.Id);

            //Assert
            _emprestimoRepositoryMockObject.Verify(p => p.Get(It.IsAny <long>()));
            _emprestimoRepositoryMockObject.Verify(p => p.Get(It.IsAny <long>()), Times.Once());
            retornoEmprestimo.Id.Should().BeGreaterThan(0);
            retornoEmprestimo.Id.Should().Be(_emprestimoDefaultWithId.Id);
        }
        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));
        }