Example #1
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);
        }
Example #2
0
        public void PagarParcela(int id, int grupo, int parcela)
        {
            Venda venda = rep.GetAll(x => x.Id == id && x.Grupo == grupo && x.Parcela == parcela)[0];

            if (venda == null)
            {
                throw new Exception("Esse pagamento/parcela não existe!");
            }

            venda.ValorPago = venda.ValorParcela;
            // venda.DataPagamento = DateTime.Now;
            rep.Update(venda);
        }
Example #3
0
        public void GetAll_Deveria_Retornar_Todos_As_Vendas()
        {
            //Arrange
            Venda resultVenda = _vendaRepository.Save(_vendaDefault);

            //Action
            IList <Venda> resultGetAll = _vendaRepository.GetAll();

            //Assert
            var ultimaVenda = resultGetAll[resultGetAll.Count - 1];

            resultGetAll.Should().NotHaveCount(0);
            resultGetAll.Should().HaveCount(2);
            ultimaVenda.Should().Equals(_vendaDefault);
        }
 public IActionResult Get()
 {
     try
     {
         return(new ObjectResult(_vendaRepository.GetAll()));
     }
     catch (Exception ex)
     {
         //Log the error (uncomment ex variable name and write a log.
         ModelState.AddModelError("", "Erro ao retornar lista de vendas." + System.Environment.NewLine + " Detalhes:" + ex.Message);
         return(BadRequest(ModelState));
     }
 }
        public void Busca_vendas_definindo_quantidade_por_valor_inicial_e_valor_maximo()
        {
            var          valorInicial = 0;
            var          valorMaximo  = 2;
            List <Venda> vendas       = _vendaRepository.GetAll(valorInicial, valorMaximo);

            Assert.AreEqual(valorMaximo, vendas.Count);

            var itensVenda = new List <ItemVenda>();

            vendas.ForEach(venda => itensVenda.AddRange(venda.ItensVenda));
            var values = itensVenda.Select(item =>
            {
                if (item.Disco == null)
                {
                    return(null);
                }
                return(item);
            }).ToList();

            Assert.IsTrue(values.Count != 0);
        }
Example #6
0
        public void GetAllShouldReturnVendaList()
        {
            // Arrange
            var veiculo = new List <Veiculo>
            {
                new Veiculo("IKG6861", "Verde", 100.00, true, true, "Hyundai", "HB20", TipoVeiculo.Carro, "Venda")
            };

            AddRange(veiculo);

            var listaVenda = new List <Venda>
            {
                new Venda(1, 80000.00, "Comprador")
            };

            AddRange(listaVenda);

            // Act
            var result = repository.GetAll();

            // Assert
            result.Should().NotBeEmpty();
            result.Should().Equals(result);
        }
Example #7
0
 public ActionResult <List <Venda> > GetAll(int paginaAtual, int quantidadeVendas)
 {
     return(_vendaRepository.GetAll(paginaAtual - 1, quantidadeVendas));
 }