示例#1
0
        public void ValidacionModificarCotizacionMonedaTest()
        {
            Repositorio   Repositorio = new Repositorio();
            ManagerMoneda unManager   = new ManagerMoneda(Repositorio);
            Moneda        MonedaVieja = new Moneda("Dolar", "USD", 43.00M);

            unManager.ValidacionAgregarMoneda(MonedaVieja);
            Moneda MonedaNueva = new Moneda("Libra", "$$", 55.00M);

            unManager.ValidacionModificacionMoneda(MonedaVieja, MonedaNueva);
            Moneda MonedaDbVieja = Repositorio.GetMonedas().Get(MonedaVieja.Id);

            Assert.AreEqual(55.00M, MonedaDbVieja.Cotizacion);
        }
        private void btn_modificar_Click(object sender, EventArgs e)
        {
            ManagerMoneda manager = new ManagerMoneda(Repo);

            if (txtNombre.Text != "" && txtSimbolo.Text != "" && nroCotizacion.Value > 0.00M && !BloqueoPesoUruguayo())
            {
                decimal Cotizacion = decimal.Parse(nroCotizacion.Text);
                try
                {
                    Moneda MonedaTemporal = new Moneda();
                    MonedaTemporal.Nombre     = txtNombre.Text;
                    MonedaTemporal.Simbolo    = txtSimbolo.Text;
                    MonedaTemporal.Cotizacion = decimal.Parse(nroCotizacion.Text);
                    manager.ValidacionModificacionMoneda(MonedaSeleccionada, MonedaTemporal);
                    MonedaSeleccionada        = new Moneda();
                    txtNombre.Text            = "";
                    txtSimbolo.Text           = "";
                    nroCotizacion.Value       = 0.00M;
                    panelModificacion.Visible = false;
                }
                catch (ExceptionNombreMoneda nombre)
                {
                    MessageBox.Show("El nombre debe ser entre 3 y 20 caracteres");
                }
                catch (ExceptionSimboloMoneda simnolo)
                {
                    MessageBox.Show("El simbolo debe ser entre 1 y 3 caracteres");
                }
                catch (ExceptionCotizacion cotizacion)
                {
                    MessageBox.Show("La cotizacion debe de ser mayor a 0");
                }
            }
            else
            {
                if (txtNombre.Text == "" || txtSimbolo.Text == "" || nroCotizacion.Value <= 0.00M)
                {
                    MessageBox.Show("Hay campos vacios");
                }
                else
                {
                    MessageBox.Show("Peso Uruguayo no se puede modificar");
                }
            }
            CargarListBox();
            txtNombre.Text     = MonedaSeleccionada.Nombre;
            txtSimbolo.Text    = MonedaSeleccionada.Simbolo;
            nroCotizacion.Text = MonedaSeleccionada.Cotizacion.ToString();
        }