Beispiel #1
0
        public void CrearCreditoTest(double valor, int plazo, double tasa, string esperado)
        {
            List <string> errores  = CreditBuilder.CanCreateCredit(valor, plazo, tasa);
            string        obtenido = errores.Contains(esperado) ? esperado : String.Join(',', errores);

            Assert.AreEqual(esperado, obtenido);
        }
Beispiel #2
0
        public void Creating_WithPositiveValue_SetsItAsNegative()
        {
            var sut = new CreditBuilder().WithNetSum(100).Build();

            var actual = sut.NetSum;

            Assert.AreEqual(-100m, actual);
        }
Beispiel #3
0
        public void AskingVatPercentage_WithDifferentVats_IsExpected(int?vatPercentage, int?expected)
        {
            var sut = new CreditBuilder().WithNetSum(100).WithVat(vatPercentage).Build();

            var actual = sut.GetVatPercentage();

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
 public void SetUp()
 {
     empleado         = new Empleado();
     empleado.Cedula  = "1065840833";
     empleado.Nombre  = "Duvan";
     empleado.Salario = 1200000;
     empleado.Creditos.Add(CreditBuilder.CrearCredito(7000000, 4));
 }
Beispiel #5
0
 public void SetUp()
 {
     empleado         = new Empleado();
     empleado.Cedula  = "1065840833";
     empleado.Nombre  = "Duvan";
     empleado.Salario = 1200000;
     empleado.Creditos.Add(CreditBuilder.CrearCredito(valor: 7000000, plazo: 4).InicializarNumero("0001"));
 }
        public void Creating_WithoutLineSumsBeingZero_ThrowsException()
        {
            var credit = new CreditBuilder().WithNetSum(100).WithVat(24).Build();
            var debit  = new DebitBuilder().WithNetSum(10).WithVat(10).Build();
            var sut    = new AccountingEntryBuilder().WithLine(credit).WithLine(debit);

            Assert.IsFalse(AccountingEntry.IsValid(new AccountingEntryLine[] { credit, debit }));
            Assert.Throws <ArgumentException>(() => sut.Build());
        }
Beispiel #7
0
        public void CréditoSolicitadoCorrecto()
        {
            CreditBuilder.CanCreateCredit(5000000, 9);
            string esperado = "El valor a total para el crédito es $5225000";
            string obtenido = "El valor a total para el crédito es $";
            var    credito  = CreditBuilder.CrearCredito(5000000, 9);

            if (credito != null)
            {
                empleado.Creditos.Add(credito);
                obtenido += credito.ValorAPagar;
            }
            Assert.AreEqual(esperado, obtenido);
        }
Beispiel #8
0
        private List <Cuota> CuotasGeneradasPorAbonoIgualACuota()
        {
            empleado         = new Empleado();
            empleado.Cedula  = "1065840833";
            empleado.Nombre  = "Duvan";
            empleado.Salario = 1200000;
            empleado.Creditos.Add(CreditBuilder.CrearCredito(7000000, 4).InicializarNumero("0001"));
            var credito = empleado.Creditos.Find(x => x.Numero == "0001");

            for (int i = 0; i < 4; i++)
            {
                credito.Cuotas[i].Estado = Estado.Pendiente;
                credito.Cuotas[i].Saldo  = 1785000;
                credito.Cuotas[i].Valor  = 1785000;
                credito.Cuotas[i].Pagado = 0;
            }
            credito.Cuotas[0].Estado = Estado.Pagado;
            credito.Cuotas[0].Saldo  = 0;
            credito.Cuotas[0].Pagado = 1785000;
            return(credito.Cuotas);
        }
Beispiel #9
0
        public Response CrearCredito(CrearCreditoRequest request)
        {
            Empleado empleado = empleadoService.GetEmpleado(request.CedulaEmpleado);

            if (empleado == null)
            {
                return(new Response()
                {
                    Mensaje = $"El número de cedula {request.CedulaEmpleado} no existe"
                });
            }
            Credito credito = GetCredito(request.Numero);

            if (credito != null)
            {
                return(new Response()
                {
                    Mensaje = $"El número de credito {request.Numero} ya existe"
                });
            }
            var errores = CreditBuilder.CanCreateCredit(request.Valor, request.Plazo, request.TasaDeInteres);

            if (errores.Any())
            {
                return(new Response()
                {
                    Mensaje = String.Join(",", errores)
                });
            }
            Credito credritoNuevo = CreditBuilder.CrearCredito(request.Valor, request.Plazo, request.TasaDeInteres);

            credritoNuevo.Numero = request.Numero;
            empleado.Creditos.Add(credritoNuevo);
            _unitOfWork.EmpleadoRepository.Edit(empleado);
            _unitOfWork.Commit();
            return(new Response()
            {
                Mensaje = $"El valor a total para el crédito es ${credritoNuevo.ValorAPagar}"
            });
        }
        public void AskingLines_WithLinesHavingDifferentVats_OrdersThemCorrectly()
        {
            var vat24 = new CreditBuilder().WithNetSum(100).WithVat(24).Build();
            var vat14 = new CreditBuilder().WithNetSum(100).WithVat(14).Build();
            var vat10 = new CreditBuilder().WithNetSum(100).WithVat(10).Build();
            var vat0  = new CreditBuilder().WithNetSum(100).WithVat(0).Build();
            var noVat = new DebitBuilder().WithNetSum(448).WithVat(null).Build();
            var sut   = new AccountingEntryBuilder()
                        .WithLine(vat14)
                        .WithLine(vat24)
                        .WithLine(vat0)
                        .WithLine(noVat)
                        .WithLine(vat10)
                        .Build();

            var actual = sut.GetLines();

            var expected = new List <AccountingEntryLine>()
            {
                noVat, vat0, vat10, vat14, vat24
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #11
0
        public void EjecutarMetodoDeCrearSinAntesValidarCAN()
        {
            string esperado = "Operacion Invalida";
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => CreditBuilder.CrearCredito(5000000, 11, 5));

            Assert.AreEqual(esperado, ex.Message);
        }