Exemplo n.º 1
0
        private void methodLookupTest(string methodName)
        {
            Type elementInterfaceType = typeof(Element);

            foreach (Type type in ModelAssembly.GetTypes())
            {
                if (type.IsClass && !type.IsAbstract && elementInterfaceType.IsAssignableFrom(type) &&
                    !isNoDeleteUndoRedoSupportClass(type))
                {
                    MethodInfo method = type.GetMethod(methodName, new Type[] { }, null);
                    Assert.IsNotNull(method, string.Format("Element of type {0} should override {1} method. ", type.Name, methodName));
                    Assert.AreEqual(method.DeclaringType, type, string.Format("Element of type {0} should override {1} method. ", type.Name, methodName));
                }
            }
        }
Exemplo n.º 2
0
        public void TestSerializeDeserializeOverride()
        {
            Type serializableType = typeof(IExolutioSerializable);

            foreach (Type type in ModelAssembly.GetTypes())
            {
                if (type.IsAmong(new Type[] { typeof(PSMSchemaClass), typeof(ExolutioVersionedObjectNotAPartOfSchema) }))
                {
                    continue;
                }

                if (type.IsClass && !type.IsAbstract && serializableType.IsAssignableFrom(type))
                {
                    TestMethodPresent(type, "Serialize");
                    TestMethodPresent(type, "Deserialize");
                }
            }
        }
Exemplo n.º 3
0
        public void TestRemovePutMeBackPairs()
        {
            Type elementInterfaceType = typeof(Element);

            foreach (Type type in ModelAssembly.GetTypes())
            {
                if (type.IsClass && !type.IsAbstract && elementInterfaceType.IsAssignableFrom(type))
                {
                    bool       no      = isNoDeleteUndoRedoSupportClass(type);
                    MethodInfo method1 = type.GetMethod("PutMeBackToModel", new Type[] { }, null);
                    MethodInfo method2 = type.GetMethod("RemoveMeFromModel", new Type[] { }, null);
                    Assert.AreEqual(method1.DeclaringType, method2.DeclaringType, string.Format("Methods RemoveMeFromModel and PutMeBackToModel should be defined both in type {0}. ", type.Name));
                    if (method1.DeclaringType == type)
                    {
                        Assert.IsFalse(no && (method1 != null || method2 != null), string.Format("PutMeBackToModel or RemoveMeFromModel are defined on type {0} which is marked with NoDeleteUndoRedoSupport attribute.", type.Name));
                    }
                    Assert.IsTrue((method1 == null && method2 == null) || (method1 != null && method2 != null), string.Format("Methods RemoveMeFromModel and PutMeBackToModel should be defined both in type {0}. ", type.Name));
                }
            }
        }
Exemplo n.º 4
0
        public void TestCloneOverride()
        {
            Type elementInterfaceType = typeof(Element);

            foreach (Type type in ModelAssembly.GetTypes())
            {
                if (type.IsClass && elementInterfaceType.IsAssignableFrom(type))
                {
                    MethodInfo method = type.GetMethod("Clone", new Type[] { typeof(Model), typeof(IDictionary <Element, Element>) });
                    if (!type.IsAbstract && !isNotCloneable(type))
                    {
                        Assert.IsNotNull(method, string.Format("Element of type {0} should override Clone method. ", type.Name));
                        Assert.AreEqual(method.DeclaringType, type, string.Format("Element of type {0} should override Clone method. ", type.Name));
                    }
                    else if (type.Name != "_Element`1")
                    {
                        Assert.IsFalse(method != null && type.IsAbstract && method.DeclaringType == type, string.Format("Element of type {0} should not override Clone method because it is abstract. ", type.Name));
                    }
                }
            }
        }