public void acreditar()
        {
            //Arrange
            ConsultasService     service       = new ConsultasService();
            TransferenciaService serv          = new TransferenciaService();
            CuentaModels         cuentaDestino = serv.getCuenta("100", 0);
            CreditoDebitoModels  debito        = new CreditoDebitoModels()
            {
                cuenta      = cuentaDestino,
                monto       = 200.00,
                descripcion = "Nota de Credito",
                fecha       = DateTime.Now,
                tipo        = 1
            };
            bool esperado = true;


            //Acts
            string msgResultado = service.acreditarDebitar(debito);

            bool resultado = msgResultado == "" ? true : false;

            //Asert
            Assert.AreEqual(esperado, resultado);
        }
        public void Test_Transferencia()
        {
            var contaSaque = new ContaCorrenteNormal();

            contaSaque.Situacao = ContaCorrenteEstado.Ativa;
            contaSaque.Saldo    = 750.00m;

            var contaDeposito = new ContaCorrenteNormal();

            contaDeposito.Situacao = ContaCorrenteEstado.Ativa;
            contaDeposito.Saldo    = 1000.00m;


            var deposito = new TransferenciaService(contaSaque, contaDeposito, 200.00m);

            deposito.Executar();

            var expectedSaque = 550.00m;
            var actualSaque   = contaSaque.Saldo;

            var expectedDeposito = 1200.00m;
            var actualDeposito   = contaDeposito.Saldo;

            Assert.AreEqual(expectedSaque, actualSaque, "Saque");
            Assert.AreEqual(expectedDeposito, actualDeposito, "Deposito");
        }
Exemplo n.º 3
0
        public TransferenciaServiceTests()
        {
            var optionsBuilder = new DbContextOptionsBuilder <BancoContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());

            _context = new BancoContext(optionsBuilder.Options);

            _transferenciaService = new TransferenciaService(_context);
        }
        public void existeCuenta()
        {
            //Arrange
            TransferenciaService serv = new TransferenciaService();
            String cuenta             = "100";
            bool   esperado           = true;
            //Acts
            bool         resultado      = false;
            CuentaModels cuenta_Destino = serv.getCuenta(cuenta, 0);

            if (cuenta_Destino != null)
            {
                resultado = true;
            }
            //Asert
            Assert.AreEqual(esperado, resultado);
        }
Exemplo n.º 5
0
        public ActionResult Transferir(String cuenta, String monto)
        {
            /* Respuesta */
            String resultado = String.Empty;
            String mensaje   = String.Empty;

            /* Realizar Transferencia */
            TransferenciaModels transferencia = new TransferenciaModels();

            transferencia.monto = double.Parse(monto.Trim());
            TransferenciaService serT = new TransferenciaService();
            DateTime             hoy  = DateTime.Today;

            transferencia.fecha          = hoy;
            transferencia.cuenta_destino = serT.getCuenta(cuenta.Trim(), 0);
            transferencia.cuenta_origen  = serT.getCuenta(Session["Usuario"].ToString(), 1);
            if (transferencia.cuenta_destino != null)
            {
                if (transferencia.cuenta_origen.saldo > transferencia.monto)
                {
                    if (serT.realizarTransferencia(transferencia))
                    {
                        resultado = "1";
                        mensaje   = "Tranferencia realizada con exito";
                    }
                    else
                    {
                        resultado = "0";
                        mensaje   = "No se pudo realizar la transferencia, intente mas tarde.";
                    }
                }
                else
                {
                    resultado = "0";
                    mensaje   = "No se pudo realizar la transferenci, el monto que desea transferir es mayor al Saldo actual.";
                }
            }
            else
            {
                resultado = "0";
                mensaje   = "No se pudó realizar la transferencia, Cuenta destino no existe.";
            }
            return(Json(new { resultado = resultado, msj = mensaje }));
        }
Exemplo n.º 6
0
        public void realizarTransferencia()
        {
            //Arrange
            TransferenciaModels transferencia = new TransferenciaModels();

            transferencia.monto = 100.00;
            TransferenciaService serT = new TransferenciaService();
            DateTime             hoy  = DateTime.Today;

            transferencia.fecha          = hoy;
            transferencia.cuenta_destino = serT.getCuenta("500", 0);
            transferencia.cuenta_origen  = serT.getCuenta("2", 1);
            bool esperado = true;

            //Acts
            bool resultado = serT.realizarTransferencia(transferencia);

            //Asert
            Assert.AreEqual(esperado, resultado);
        }
Exemplo n.º 7
0
        public void verificarMonto()
        {
            //Arrange
            TransferenciaService serv = new TransferenciaService();
            String usuario            = "2";
            double monto    = 10.00;
            bool   esperado = true;
            //Acts
            CuentaModels cuenta_Origen = serv.getCuenta(usuario, 1);
            bool         resultado     = false;

            if (cuenta_Origen != null)
            {
                if (cuenta_Origen.saldo > monto)
                {
                    resultado = true;
                }
            }

            //Asert
            Assert.AreEqual(esperado, resultado);
        }
Exemplo n.º 8
0
 public ActionResult Debitar(string cuenta, string monto, string descripcion)
 {
     try
     {
         TransferenciaService service       = new TransferenciaService();
         CuentaModels         cuentaDestino = service.getCuenta(cuenta.Trim(), 0);
         if (cuentaDestino != null)
         {
             CreditoDebitoModels debito = new CreditoDebitoModels()
             {
                 cuenta      = cuentaDestino,
                 monto       = Convert.ToDouble(monto),
                 descripcion = descripcion,
                 fecha       = DateTime.Now,
                 tipo        = 0
             };
             string msgResultado = consultaService.acreditarDebitar(debito);
             if (msgResultado != "")
             {
                 ViewBag.MsgSaldo += "Error: " + msgResultado;
                 return(View("Debito"));
             }
             ViewBag.MsgSaldo = "Debitacion exitosa";
             return(View("Debito"));
         }
         else
         {
             ViewBag.MsgSaldo = "No existe cuenta Destino, favor verificar.";
             return(View("Debito"));
         }
     }
     catch (Exception)
     {
         ViewBag.MsgSaldo += "Hay problemas al realizar el debito o hay datos incorrectos";
         return(View("Debito"));
     }
 }
Exemplo n.º 9
0
        public void Setup()
        {
            this.unitOfWork           = Dependency.Resolve <IUnitOfWork>();
            this.contaRepository      = Dependency.Resolve <ContaRepository>();
            this.categoriaRepository  = Dependency.Resolve <CategoriaRepository>();
            this.fechaMovimento       = Dependency.Resolve <FechaMovimentoService>();
            this.transferenciaService = Dependency.Resolve <TransferenciaService>();
            this.gastoService         = Dependency.Resolve <GastoService>();
            this.recebimentoService   = Dependency.Resolve <RecebimentoService>();
            this.abreMovimentoService = Dependency.Resolve <AbreMovimentoService>();
            this.fluxoCaixaService    = Dependency.Resolve <FluxoCaixaService>();

            using (this.unitOfWork.Begin())
            {
                Dependency.Resolve <DatabaseCleaner>().Execute();
            }

            using (this.unitOfWork.Begin())
            {
                this.contaRepository.Seed();
                this.categoriaRepository.Seed();
            }

            using (this.unitOfWork.Begin())
            {
                this.caixa = this.contaRepository.ById(Conta.CaixaId);
                this.itau  = this.contaRepository.ById(Conta.ItauId);

                this.proLabore   = this.categoriaRepository.ByNome("Pró-Labore");
                this.aluguel     = this.categoriaRepository.ByNome("Aluguel");
                this.vendas      = this.categoriaRepository.ByNome("Vendas 206");
                this.compras     = this.categoriaRepository.ByNome("Compras");
                this.combustivel = this.categoriaRepository.ByNome("Combustível");
                this.energia     = this.categoriaRepository.ByNome("Energia");
            }
        }
Exemplo n.º 10
0
 public TransferenciaController(ContaRepository contaRepository, TransferenciaService transferenciaService)
 {
     this.contaRepository      = contaRepository;
     this.transferenciaService = transferenciaService;
 }
Exemplo n.º 11
0
 public ContaCorrenteTests()
 {
     this.ContaCorrenteService = new ContaCorrenteService();
     this.SpbQueueService      = new SPBQueueService();
     this.TransferenciaService = new TransferenciaService(this.ContaCorrenteService, this.SpbQueueService);
 }