示例#1
0
        public void     TestConstantsDuplicate()
        {
            Type type = typeof(Metrics);

            FieldInfo[] fields    = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
            int         constants = 0;

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].IsLiteral == false || fields[i].FieldType != typeof(int))
                {
                    continue;
                }

                int v = (int)fields[i].GetRawConstantValue();

                if ((constants & (1 << (v - 1))) == 0)
                {
                    constants |= (1 << (v - 1));
                    NGAssert.AssertBoolTrue(true, "Field " + fields[i].Name + " (" + v + ") is valid.");
                }
                else
                {
                    NGAssert.AssertBoolTrue(false, "Field " + fields[i].Name + " (" + v + ") is valid.");
                }
            }
        }
示例#2
0
        public void     Test()
        {
            foreach (Type type in Utility.EachNGTSubClassesOf(typeof(ComponentExposer)))
            {
                ComponentExposer test   = Activator.CreateInstance(type) as ComponentExposer;
                FieldInfo[]      fields = test.GetFieldInfos();

                InternalNGDebug.Log("Testing exposer " + type.Name);

                for (int i = 0; i < fields.Length; i++)
                {
                    NGAssert.AssertBoolTrue(fields[i] != null && fields[i].IsDefined(typeof(ObsoleteAttribute), false) == false, "Field " + i + " is good.");
                }

                PropertyInfo[] properties = test.GetPropertyInfos();

                for (int i = 0; i < properties.Length; i++)
                {
                    NGAssert.AssertBoolTrue(properties[i] != null && properties[i].IsDefined(typeof(ObsoleteAttribute), false) == false, "Property " + i + " is good.");
                }
            }
        }