static FbxLayerElementTestBase() { s_createFromLayerContainerAndName = typeof(T).GetMethod("Create", new System.Type[] { typeof(FbxLayerContainer), typeof(string) }); s_getDirectArray = typeof(T).GetMethod("GetDirectArray"); s_getIndexArray = typeof(T).GetMethod("GetIndexArray"); #if ENABLE_COVERAGE_TEST // Register the calls we make through reflection. // We use reflection in CreateObject(FbxLayerContainer, string) if (s_createFromLayerContainerAndName != null) { var createFromLayerContainerAndName = typeof(FbxLayerElementTestBase <T>).GetMethod("CreateObject", new System.Type[] { typeof(FbxLayerContainer), typeof(string) }); CoverageTester.RegisterReflectionCall(createFromLayerContainerAndName, s_createFromLayerContainerAndName); } if (s_getDirectArray != null) { var getDirectArray = typeof(FbxLayerElementTestBase <T>).GetMethod("GetDirectArray"); CoverageTester.RegisterReflectionCall(getDirectArray, s_getDirectArray); } if (s_getIndexArray != null) { var getIndexArray = typeof(FbxLayerElementTestBase <T>).GetMethod("GetIndexArray"); CoverageTester.RegisterReflectionCall(getIndexArray, s_getIndexArray); } #endif }
static FbxConstraintDescendantTestBase() { s_AddConstraintSource = typeof(T).GetMethod("AddConstraintSource", new System.Type[] { typeof(FbxObject) }); s_AddConstraintSourceDouble = typeof(T).GetMethod("AddConstraintSource", new System.Type[] { typeof(FbxObject), typeof(double) }); s_SetConstrainedObject = typeof(T).GetMethod("SetConstrainedObject", new System.Type[] { typeof(FbxObject) }); #if ENABLE_COVERAGE_TEST // Register the calls we make through reflection. if (s_AddConstraintSource != null) { var addConstraintSource = typeof(FbxConstraintDescendantTestBase <T>).GetMethod("AddConstraintSource"); CoverageTester.RegisterReflectionCall(addConstraintSource, s_AddConstraintSource); } if (s_AddConstraintSourceDouble != null) { var addConstraintSourceDouble = typeof(FbxConstraintDescendantTestBase <T>).GetMethod("AddConstraintSourceDouble"); CoverageTester.RegisterReflectionCall(addConstraintSourceDouble, s_AddConstraintSourceDouble); } if (s_SetConstrainedObject != null) { var setConstrainedObject = typeof(FbxConstraintDescendantTestBase <T>).GetMethod("SetConstrainedObject"); CoverageTester.RegisterReflectionCall(setConstrainedObject, s_SetConstrainedObject); } #endif }
static FbxMeshBadBracketingExceptionTest() { // We don't test Exception.GetObjectData ; we assume that the C# // compiler and runtime can make it work. CoverageTester.RegisterReflectionCall( typeof(FbxMeshBadBracketingExceptionTest).GetMethod("BasicTests"), typeof(FbxMesh.BadBracketingException).GetMethod("GetObjectData")); }
/** * The coverage tester won't track the calls that MatchingTests makes * to the lambda functions. Call this function in your static * constructor to register the calls. * * This is accurate because MatchingTests makes sure that every command * was actually issued. */ public static void RegisterLambdaCalls <T>( System.Reflection.MethodInfo caller, Dictionary <string, TestCommand <T> > commands) { foreach (var lambda in commands.Values) { CoverageTester.RegisterReflectionCall(caller, lambda.Method); } }
static FbxLayerElementArrayTemplateTestBase() { s_getAt = typeof(T).GetMethod("GetAt", new System.Type[] { typeof(int) }); s_constructor = typeof(T).GetConstructor(System.Type.EmptyTypes); #if ENABLE_COVERAGE_TEST // Register the calls we make through reflection. if (s_getAt != null) { var getAt = typeof(FbxLayerElementArrayTemplateTestBase <T, U>).GetMethod("GetAt"); CoverageTester.RegisterReflectionCall(getAt, s_getAt); } if (s_constructor != null) { var constructor = typeof(FbxLayerElementArrayTemplateTestBase <T, U>).GetMethod("CreateObject"); CoverageTester.RegisterReflectionCall(constructor, s_constructor); } #endif }
static Base() { s_createFromMgrAndName = typeof(T).GetMethod("Create", new System.Type[] { typeof(FbxManager), typeof(string) }); s_createFromObjAndName = typeof(T).GetMethod("Create", new System.Type[] { typeof(FbxObject), typeof(string) }); #if ENABLE_COVERAGE_TEST // Register the calls we make through reflection. // We use reflection in CreateObject(FbxManager, string) and CreateObject(FbxObject, string). if (s_createFromMgrAndName != null) { var createFromMgrAndName = typeof(Base <T>).GetMethod("CreateObject", new System.Type[] { typeof(FbxManager), typeof(string) }); CoverageTester.RegisterReflectionCall(createFromMgrAndName, s_createFromMgrAndName); } if (s_createFromObjAndName != null) { var createFromObjAndName = typeof(Base <T>).GetMethod("CreateObject", new System.Type[] { typeof(FbxObject), typeof(string) }); CoverageTester.RegisterReflectionCall(createFromObjAndName, s_createFromObjAndName); } #endif }
static GlobalsTest() { /* We test the PINVOKE class by reflection since it's private to * its assembly. */ var alltypes = typeof(Autodesk.Fbx.Globals).Assembly.GetTypes(); foreach (var t in alltypes) { if (t.Namespace == "Autodesk.Fbx" && t.Name == kPINVOKE) { s_PINVOKEtype = t; break; } } Assert.IsNotNull(s_PINVOKEtype); s_PINVOKEctor = s_PINVOKEtype.GetConstructor(new System.Type[] {}); foreach (var m in s_PINVOKEtype.GetMethods()) { if (m.Name.EndsWith("SWIGUpcast")) { s_UpcastFunctions.Add(m); } } #if ENABLE_COVERAGE_TEST var basicTests = typeof(GlobalsTest).GetMethod("BasicTests"); if (s_PINVOKEctor != null) { CoverageTester.RegisterReflectionCall(basicTests, s_PINVOKEctor); } foreach (var m in s_UpcastFunctions) { CoverageTester.RegisterReflectionCall(basicTests, m); } #endif }
static EqualityTester() { // For T and its base classes B1, B2, ... // get the following functions so we can test equality: // bool Equals(U) // static bool operator == (U, U) // static bool operator != (U, U) var U = typeof(T); do { // Get all the methods, look for Equals(U), op_Equality(U,U), and op_Inequality(U,U) var methods = U.GetMethods(); foreach (var method in methods) { if (method.Name == "Equals") { var parms = method.GetParameters(); if (parms.Length == 1 && parms[0].ParameterType == U) { s_Equals.Add(method); } } else if (method.Name == "op_Equality") { var parms = method.GetParameters(); if (parms.Length == 2 && parms[0].ParameterType == U && parms[1].ParameterType == U) { s_op_Equality.Add(method); } } else if (method.Name == "op_Inequality") { var parms = method.GetParameters(); if (parms.Length == 2 && parms[0].ParameterType == U && parms[1].ParameterType == U) { s_op_Inequality.Add(method); } } } // Repeat on the base type, if there is one. U = U.BaseType; } while (U != null); #if ENABLE_COVERAGE_TEST // Register the calls we make through reflection. var testEquality = typeof(EqualityTester <T>).GetMethod("TestEquality"); foreach (var equals in s_Equals) { CoverageTester.RegisterReflectionCall(testEquality, equals); } foreach (var equals in s_op_Equality) { CoverageTester.RegisterReflectionCall(testEquality, equals); } foreach (var equals in s_op_Inequality) { CoverageTester.RegisterReflectionCall(testEquality, equals); } #endif }