Ejemplo n.º 1
0
        public void Reflex_GetPropertyValue_object_sinPropiedades_str_throw_ex()
        {
            // Prepara
            ClasePruebaSinPropiedades objeto = new ClasePruebaSinPropiedades();

            try
            {
                // Ejecuta
                object value = Reflex.GetPropertyValue(objeto, "FieldInt");
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                // Comprueba
                Assert.AreEqual("Error en argumento objeto. objeto no tiene propiedades para conseguir valores.", ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void Reflex_GetPropertyValue_object_null_str_throw_ex()
        {
            // Prepara
            ClasePruebaPropiedadesKeys objeto = null;

            try
            {
                // Ejecuta
                object value = Reflex.GetPropertyValue(objeto, "FieldInt");
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                // Comprueba
                Assert.AreEqual("Error en argumento objeto. objeto nulo.", ex.Message);
            }
        }
Ejemplo n.º 3
0
        public void Reflex_GetPropertyValue_object_str_ret_object()
        {
            // Prepara
            DateTime ahora = DateTime.Now;
            ClasePruebaPropiedadesKeys objeto = new ClasePruebaPropiedadesKeys
            {
                FieldBool = true,
                FieldDT   = ahora,
                FieldInt  = 100,
                FieldStr  = "Test"
            };

            // Ejecuta
            int value = (int)Reflex.GetPropertyValue(objeto, "FieldInt");

            // Comprueba
            Assert.AreEqual(100, value);
        }
Ejemplo n.º 4
0
        public void Reflex_GetPropertyValue_object_str_objetoNoTinePropiedad_throw_ex()
        {
            // Prepara
            DateTime ahora = DateTime.Now;
            ClasePruebaPropiedadesKeys objeto = new ClasePruebaPropiedadesKeys
            {
                FieldBool = true,
                FieldDT   = ahora,
                FieldInt  = 100,
                FieldStr  = "Test"
            };

            try
            {
                // Ejecuta
                object value = Reflex.GetPropertyValue(objeto, "PropertyNoExist");
                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                // Comprueba
                Assert.AreEqual("Error en argumento propertyName. objeto no tiene propiedad 'PropertyNoExist'.", ex.Message);
            }
        }