private void button1_Click(object sender, EventArgs e)
        {
            ManagerPresupuesto manager = new ManagerPresupuesto(Repo);

            if (nmr_Año.Text != "" && cboMes.SelectedIndex != -1)
            {
                Presupuesto PresupuestoGuardar = new Presupuesto();
                try
                {
                    PresupuestoGuardar.Año = int.Parse(nmr_Año.Text);
                    PresupuestoGuardar.Mes = (String)cboMes.SelectedItem;
                    PresupuestoGuardar.setPresupuestosCategorias(PresupuestoTemporal.getPresupuestosCategorias());
                    manager.ValidacionAgregarPresupuesto(PresupuestoGuardar);
                    nmr_Año.Text         = "";
                    cboMes.SelectedIndex = -1;
                    PresupuestoTemporal  = new Presupuesto();
                    manager.CargarCategoriasPresupuesto(PresupuestoTemporal);
                    CargarList();
                }
                catch (ExceptionAñoPresupuesto año)
                {
                    MessageBox.Show("El año tiene que ser entre 2018 - 2030");
                }
                catch (ExceptionPresupuestoRepetido repetido)
                {
                    MessageBox.Show("Presupuesto para año y mes ya ingresado");
                }
            }
            else
            {
                MessageBox.Show("Los campos Año y Mes son obligatorios");
            }
        }
예제 #2
0
        public void PresupuestoRepetidoTest()
        {
            Repositorio        Repositorio   = new Repositorio();
            ManagerPresupuesto Manager       = new ManagerPresupuesto(Repositorio);
            Presupuesto        UnPresupuesto = new Presupuesto(2020, "Octubre", new List <MontoCategoria>());

            Repositorio.AgregarPresupuesto(UnPresupuesto);
            Manager.ValidacionAgregarPresupuesto(UnPresupuesto);
        }
예제 #3
0
        public void ValidacionAgregarPresupuestoTest()
        {
            Repositorio        Repositorio  = new Repositorio();
            ManagerPresupuesto Manager      = new ManagerPresupuesto(Repositorio);
            Categoria          UnaCategoria = new Categoria("Entretenimiento");

            Repositorio.AgregarCategoria(UnaCategoria);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2018;
            unPresupuesto.Mes = "Julio";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            Assert.AreEqual(Repositorio.GetPresupuestos().GetAll()[0].Año, 2018);
        }
예제 #4
0
        public void CargarCategoriasAPresupuestoTest()
        {
            Repositorio        Repositorio = new Repositorio();
            ManagerPresupuesto Manager     = new ManagerPresupuesto(Repositorio);
            Categoria          Categoria1  = new Categoria("Entretenimiento");
            Categoria          Categoria2  = new Categoria("Cine");

            Repositorio.AgregarCategoria(Categoria1);
            Repositorio.AgregarCategoria(Categoria2);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2020;
            unPresupuesto.Mes = "Ebola";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            Assert.AreEqual(unPresupuesto.PresupuestosCategorias[1].Cat.Id, Categoria2.Id);
        }
예제 #5
0
        public void AgregarUnMontoTest()
        {
            Repositorio        Repositorio = new Repositorio();
            ManagerPresupuesto Manager     = new ManagerPresupuesto(Repositorio);
            Categoria          Categoria1  = new Categoria("Entretenimiento");
            Categoria          Categoria2  = new Categoria("Cine");

            Repositorio.AgregarCategoria(Categoria1);
            Repositorio.AgregarCategoria(Categoria2);
            Presupuesto unPresupuesto = new Presupuesto();

            unPresupuesto.Año = 2020;
            unPresupuesto.Mes = "Febrero";
            Manager.ValidacionAgregarPresupuesto(unPresupuesto);
            Manager.CargarCategoriasPresupuesto(unPresupuesto);
            decimal unMonto = 1200.00M;

            Manager.ValidacionAgregarUnMonto(unPresupuesto, Categoria1, unMonto);
            Assert.AreEqual(unPresupuesto.PresupuestosCategorias[0].Monto, unMonto);
        }
예제 #6
0
        public void ValidacionModificacionPresupuestoTest()
        {
            Repositorio        Repositorio  = new Repositorio();
            ManagerPresupuesto Manager      = new ManagerPresupuesto(Repositorio);
            Categoria          UnaCategoria = new Categoria("Entretenimiento");

            Repositorio.AgregarCategoria(UnaCategoria);
            MontoCategoria        unMonto = new MontoCategoria(UnaCategoria, 0.00M);
            List <MontoCategoria> montos  = new List <MontoCategoria>();

            montos.Add(unMonto);
            int         unAño            = 2018;
            string      unMes            = "Julio";
            Presupuesto presupuestoNuevo = new Presupuesto(unAño, unMes, montos);

            Manager.ValidacionAgregarPresupuesto(presupuestoNuevo);
            decimal nuevoMontoDeC1 = 15000.00M;

            Manager.ValidacionModificarPresupuesto(Repositorio.GetPresupuestos().GetAll()[0], UnaCategoria, nuevoMontoDeC1);
            Assert.AreEqual(Repositorio.GetPresupuestos().GetAll()[0].getPresupuestosCategorias()[0].Monto, nuevoMontoDeC1);
        }