コード例 #1
0
        public void Reflex_GetPropertiesNameAndValue_object_sinPropiedades_ListPIs_null_ret_null()
        {
            // Prepara
            ClasePruebaSinPropiedades objeto = new ClasePruebaSinPropiedades
            {
                Field = null
            };
            List <PropertyInfo> pis = Reflex.GetPropertiesInfoWithAttributes(objeto, typeof(FieldAttribute));

            // Ejecuta
            Dictionary <string, object> dicProperties = Reflex.GetPropertiesNameAndValue(objeto, pis);

            // Comprueba
            Assert.IsNull(dicProperties);
        }
コード例 #2
0
        public void Reflex_GetPropertiesNameAndValue_object_sinLosAtributos_ListPIs_null_ret_null()
        {
            // Prepara
            ClasePruebaPropiedadesFields objeto = new ClasePruebaPropiedadesFields
            {
                FieldBool = true,
                FieldDT   = DateTime.MinValue,
                FieldInt  = 0,
                FieldStr  = string.Empty
            };
            List <PropertyInfo> pis = Reflex.GetPropertiesInfoWithAttributes(objeto, typeof(KeyAttribute));

            // Ejecuta
            Dictionary <string, object> dicProperties = Reflex.GetPropertiesNameAndValue(objeto, pis);

            // Comprueba
            Assert.IsNull(dicProperties);
        }
コード例 #3
0
        public void Reflex_GetPropertiesNameAndValue_object_ListPIs_ret_Dictionary_str_object()
        {
            // Prepara
            DateTime dtAhora = DateTime.Now;
            ClasePruebaPropiedadesFields objeto = new ClasePruebaPropiedadesFields
            {
                FieldBool = true,
                FieldDT   = dtAhora,
                FieldInt  = 115,
                FieldStr  = "Hello World!"
            };
            List <PropertyInfo> pis = Reflex.GetPropertiesInfoWithAttributes(objeto, typeof(FieldAttribute));

            // Ejecuta
            Dictionary <string, object> dicProperties = Reflex.GetPropertiesNameAndValue(objeto, pis);

            // Comprueba
            Assert.AreEqual(true, (bool)dicProperties["FieldBool"]);
            Assert.AreEqual(dtAhora, (DateTime)dicProperties["FieldDT"]);
            Assert.AreEqual(115, (int)dicProperties["FieldInt"]);
            Assert.AreEqual("Hello World!", (string)dicProperties["FieldStr"]);
        }