public void CreateVendaInvalidProduto()
        {
            Venda  venda = ObjectMotherVenda.getInvalidProduto();
            Action act   = venda.valida;

            act.Should().Throw <VendaExceptionIsProdutoNull>();
        }
Exemple #2
0
        public void VendaRepository_Delete_ShouldBeFail()
        {
            Venda  vendas = ObjectMotherVenda.getValidVenda();
            Action delete = () => _repository.Delete(vendas);

            delete.Should().Throw <IdentifierUndefinedException>();
        }
        public void CreateVendaInvalidOverflowQuantidade()
        {
            Venda  venda = ObjectMotherVenda.getInValidQuantidadeOverflow();
            Action act   = venda.valida;

            act.Should().Throw <VendaQuantidadeOverflow>();
        }
Exemple #4
0
        public void Venda_Validate_ShouldBeOK()
        {
            Venda  venda    = ObjectMotherVenda.getValidVenda();
            Action validate = () => venda.Validate();

            validate.Should().NotThrow <Exception>();
        }
        public void CreateVendaInvalidOverflowNomeCliente()
        {
            Venda  venda = ObjectMotherVenda.getInvalidMessageOverflow();
            Action act   = venda.valida;

            act.Should().Throw <VendaIsNullOrEmptyNome>();
        }
Exemple #6
0
        public void VendaIntegration_Delete_ShouldBeFail()
        {
            //Executa
            Action comparison = () => _service.Delete(ObjectMotherVenda.getValidVenda());

            //Saída
            comparison.Should().Throw <IdentifierUndefinedException>();
        }
        public void CreateVendaValid()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 1;
            venda.valida();
            venda.Id.Should().Be(1);
        }
Exemple #8
0
        public void VendaRepository_Update_ShouldBeFail()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 0;
            Action update = () => _repository.Update(venda);

            update.Should().Throw <IdentifierUndefinedException>();
        }
Exemple #9
0
        public void Venda_ValidateDisponibilidade_ShouldBeOK()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.produtoVenda.Disponibilidade = false;
            Action validate = () => venda.Validate();

            validate.Should().Throw <DisponibilidadeException>();
        }
Exemple #10
0
        public void Venda_ValidateValidade_ShouldBeOK()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.produtoVenda.DataValidade = DateTime.Now.AddDays(-9);
            Action validate = () => venda.Validate();

            validate.Should().Throw <ValidadeException>();
        }
Exemple #11
0
        public void VendaRepository_Update_ShouldBeOk()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 2;
            var vendaEditar = _repository.Update(venda);

            vendaEditar.cliente.Should().Be(venda.cliente);
        }
Exemple #12
0
        public void VendaRespository_Add_ShouldBeOk()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 2;
            _repository.Save(venda);
            var vendas = _repository.GetAll();

            vendas.Count().Should().BeGreaterThan(0);
        }
Exemple #13
0
        public void VendaRespository_AddValidate_ShouldBeFail()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 2;
            venda.produtoVenda.DataValidade = DateTime.Now.AddDays(-8);
            Action salvar = () => _repository.Save(venda);

            salvar.Should().Throw <ValidadeException>();
        }
Exemple #14
0
        public void VendaIntegration_Add_Nome_ShouldBeFail()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.produtoVenda.DataValidade = DateTime.Now.AddDays(-9);

            Action comparison = () => _service.Save(venda);

            comparison.Should().Throw <ValidadeException>();
        }
Exemple #15
0
        public void VendaIntegration_Update_Invalid_Id_ShouldBeFail()
        {
            //Cenário
            Venda modelo = ObjectMotherVenda.getValidVenda();

            //Executa
            Action comparison = () => _service.Update(modelo);

            //Saída
            comparison.Should().Throw <IdentifierUndefinedException>();
        }
Exemple #16
0
        public void VendaRepository_Delete_ShouldBeOk()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 1;

            _repository.Delete(venda);
            Venda deleteObject = _repository.Get(1);

            deleteObject.Should().BeNull();
        }
Exemple #17
0
        public void VendaService_Update_Invalid_Id_ShouldBeFail()
        {
            Venda modelo = ObjectMotherVenda.getValidVenda();

            modelo.Id = 0;

            VendaService service = new VendaService(_mockRepository.Object);

            Action comparison = () => service.Update(modelo);

            comparison.Should().Throw <IdentifierUndefinedException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Exemple #18
0
        public void VendaService_Add_ShouldBeFail()
        {
            Venda modelo = ObjectMotherVenda.getValidVenda();

            modelo.produtoVenda.DataValidade = DateTime.Now.AddDays(-9);

            VendaService service = new VendaService(_mockRepository.Object);

            Action comparison = () => service.Save(modelo);

            comparison.Should().Throw <ValidadeException>();
            _mockRepository.VerifyNoOtherCalls();
        }
Exemple #19
0
        public void VendaIntegration_Update_Nome_ShouldBeFail()
        {
            //Cenário
            Venda modelo = ObjectMotherVenda.getValidVenda();

            modelo.Id = 1;
            modelo.produtoVenda.DataValidade = DateTime.Now.AddDays(-9);

            //Executa
            Action comparison = () => _service.Update(modelo);

            //Saída
            comparison.Should().Throw <ValidadeException>();
        }
Exemple #20
0
        public void VendaService_Get_ShouldBeOk()
        {
            Venda produto = ObjectMotherVenda.getValidVenda();

            produto.Id = 3;

            _mockRepository.Setup(m => m.Get(3)).Returns(produto);

            VendaService service   = new VendaService(_mockRepository.Object);
            Venda        resultado = service.Get(3);

            resultado.Should().NotBeNull();
            _mockRepository.Verify(repository => repository.Get(3));
        }
Exemple #21
0
        public void VendaService_Delete_ShouldBeOk()
        {
            Venda modelo = ObjectMotherVenda.getValidVenda();

            modelo.Id = 1;

            _mockRepository.Setup(m => m.Delete(modelo));


            VendaService service = new VendaService(_mockRepository.Object);

            service.Delete(modelo);

            _mockRepository.Verify(repository => repository.Delete(modelo));
        }
Exemple #22
0
        public void VendaIntegration_Update_ShouldBeOk()
        {
            //Cenário
            Venda modelo = ObjectMotherVenda.getValidVenda();

            modelo.Id = 1;

            //Executa
            Venda venda = _service.Update(modelo);

            //Saída
            venda.Should().NotBeNull();
            venda.Id.Should().Be(modelo.Id);
            venda.cliente.Should().Be(modelo.cliente);
        }
Exemple #23
0
        public void VendaService_Add_ShouldBeOK()
        {
            Venda produto = ObjectMotherVenda.getValidVenda();

            _mockRepository.Setup(m => m.Save(produto)).Returns(new Venda()
            {
                Id = 1
            });
            VendaService service = new VendaService(_mockRepository.Object);

            Venda resultado = service.Save(produto);

            resultado.Should().NotBeNull();
            resultado.Id.Should().BeGreaterThan(0);
            _mockRepository.Verify(repository => repository.Save(produto));
        }
Exemple #24
0
        public void VendaIntegration_Add_ShouldBeOk()
        {
            //Executa
            Venda venda = _service.Save(ObjectMotherVenda.getValidVenda());

            //Saída
            venda.Id.Should().BeGreaterThan(0);

            var last = _service.Get(venda.Id);

            last.Should().NotBeNull();

            var posts = _service.GetAll();

            posts.Count().Should().BeGreaterThan(0);
        }
Exemple #25
0
        public void VendaIntegration_Delete_ShouldBeOk()
        {
            Venda venda = ObjectMotherVenda.getValidVenda();

            venda.Id = 2;
            //Executa
            _service.Delete(venda);

            //Saída
            Venda vendadel = _service.Get(2);

            vendadel.Should().BeNull();

            List <Venda> posts = _service.GetAll() as List <Venda>;

            posts.Count().Should().Be(1);
        }
Exemple #26
0
        public void VendaService_Update_ShouldBeOK()
        {
            Venda produto = ObjectMotherVenda.getValidVenda();

            produto.Id = 2;

            _mockRepository.Setup(m => m.Update(produto)).Returns(new Venda()
            {
                Id         = 2,
                cliente    = "Pedro",
                quantidade = 1
            });

            VendaService service = new VendaService(_mockRepository.Object);


            Venda resultado = service.Update(produto);

            resultado.Should().NotBeNull();
            resultado.cliente.Should().Be("Pedro");
            _mockRepository.Verify(repository => repository.Update(produto));
        }