Beispiel #1
0
        public void RecuperarEgresoTest()
        {
            Egreso_Logica egreso_Logica = new Egreso_Logica();
            List <Egreso> listaRecibida = egreso_Logica.RecuperarEgreso();
            List <Egreso> listaEsperada = new List <Egreso>();

            listaEsperada.Add(new Egreso()
            {
                Id       = 2,
                concepto = "compra sillas",
                fecha    = new DateTime(2020, 04, 12),
                monto    = 150
            });
            listaEsperada.Add(new Egreso()
            {
                Id       = 3,
                concepto = "prueba parte dos",
                fecha    = new DateTime(2020, 04, 12),
                monto    = 46485
            });
            listaEsperada.Add(new Egreso()
            {
                Id       = 7,
                concepto = "PruebaFinal",
                fecha    = new DateTime(2020, 04, 17),
                monto    = 38
            });


            listaRecibida.Should().BeEquivalentTo(listaEsperada);
        }
        private bool NuevoEgreso()
        {
            Egreso nuevoEgreso = new Egreso()
            {
                concepto = textBox_concepto.Text,
                fecha    = Convert.ToDateTime(textBox_fecha.Text),
                monto    = float.Parse(textBox_monto.Text, NumberFormatInfo.InvariantInfo)
            };
            Egreso_Logica egreso_Logica = new Egreso_Logica();

            if (!egreso_Logica.ComprobarConexion())
            {
                textBlock_mensaje.Text = String.Empty;
                var bold = new Bold(new Run("Se ha perdido conexión con la base de datos")
                {
                    Foreground = Brushes.Red
                });
                textBlock_mensaje.Inlines.Add(bold);
                return(true);
            }
            egreso_Logica.RegistrarEgreso(nuevoEgreso);
            if (textBox_tipo.IsVisible)
            {
                Material nuevoMaterial = new Material()
                {
                    cantidad = int.Parse(textBox_cantidad.Text),
                    costo    = double.Parse(textBox_costo.Text, NumberFormatInfo.InvariantInfo),
                    tipo     = textBox_tipo.Text
                };
                Material_Logica material_Logica = new Material_Logica();
                material_Logica.RegistrarMaterial(
                    nuevoMaterial,
                    egreso_Logica.RecuperarEgreso().Last().Id);
            }
            return(true);
        }