Ejemplo n.º 1
0
        public void FieldValueTest()
        {
            Type          o;
            object        fromObj;
            TypeProcessor processor = new TypeProcessor(typeof(TestType));

            fromObj = processor.CreateInstance();
            processor.SetField(fromObj, "A", new TestType());
            processor.SetField(fromObj, "B", new TestType());
            processor.SetField(fromObj, "C", new TestType());
            processor.SetField(fromObj, "D", new TestType());
            processor.SetField(fromObj, "E", new TestType());
            processor.SetField(fromObj, "F", new TestType());
            processor.SetField(fromObj, "G", new TestType());
            processor.SetField(fromObj, "H", new TestType());
            processor.SetField(fromObj, "I", "I");
            processor.SetField(fromObj, "J", 99);
            processor.SetField(fromObj, "K", true);


            for (int i = 0; i < 10; i++)
            {
                var ToObj = processor.CreateInstance();
                foreach (FieldInfo item in fromObj.GetType().GetFields())
                {
                    processor.SetField(ToObj, item.Name, processor.GetField(fromObj, item.Name));
                    if (!processor.GetField(fromObj, item.Name).Equals(processor.GetField(ToObj, item.Name)))
                    {
                        Assert.Fail();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void VoidCallWithGenericType(Type type, string methodName, Type[] genericsType, Type[] parametersType, params object[] args)
        {
            TypeProcessor processor     = new TypeProcessor(type, null, null);
            object        instance      = processor.CreateInstance();
            string        resultCompare = genericsType[0].Name;

            processor.VoidCall(instance, methodName, genericsType, parametersType, args);
            if (args != null)
            {
                foreach (var item in args)
                {
                    resultCompare += (string)item;
                }
            }
            string reslut = (string)processor.GetProperty(instance, "GenericTypeName") + (string)processor.GetField(instance, "I");

            if (reslut != resultCompare)
            {
                Assert.Fail();
            }
        }