コード例 #1
0
        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
        }
コード例 #2
0
        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
        }
コード例 #3
0
 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"));
 }
コード例 #4
0
 /**
  * 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);
     }
 }
コード例 #5
0
        public void TestCoverage()
        {
            /* Search the current assembly for unit tests. */
            var alltypes        = GetType().Assembly.GetTypes();
            var unitTestMethods = new List <MethodBase>();

            foreach (var t in alltypes)
            {
                CoverageTester.CollectTestMethods(t, unitTestMethods);
            }

            /* Search the assembly that Autodesk.Fbx.Globals is in to find classes in
             * the FbxSdk namespace to test. */
            alltypes = typeof(Autodesk.Fbx.Globals).Assembly.GetTypes();
            var methodsToCover = new List <MethodBase>();

            foreach (var t in alltypes)
            {
                if (t.Namespace != "Autodesk.Fbx")
                {
                    continue;
                }

                /* don't take in delegates; we can't properly track coverage,
                 * so just avoid the false negative */
                if (t.IsSubclassOf(typeof(System.Delegate)))
                {
                    continue;
                }

                /* take in the PINVOKE class but skip its helper classes */
                bool skip = false;
                for (var u = t.DeclaringType; u != null; u = u.DeclaringType)
                {
                    if (u.TypeHandle.Value == s_PINVOKEtype.TypeHandle.Value)
                    {
                        skip = true;
                        break;
                    }
                }
                if (skip)
                {
                    continue;
                }

                CoverageTester.CollectMethodsToCover(t, methodsToCover);
            }

            List <MethodBase> hitMethods    = new List <MethodBase>();
            List <MethodBase> missedMethods = new List <MethodBase>();
            var ok = CoverageTester.TestCoverage(methodsToCover, unitTestMethods, out hitMethods, out missedMethods);

            NUnit.Framework.Assert.That(
                () => ok,
                () => CoverageTester.MakeCoverageMessage(hitMethods, missedMethods));
        }
コード例 #6
0
 public override void TestCoverage()
 {
     // This test is also responsible for FbxBindingTableBase and FbxBindingTableEntry
     base.TestCoverage();
     CoverageTester.TestCoverage(typeof(FbxBindingTableBase), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxBindingTableEntry), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxEntryView), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEntryView), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxSemanticEntryView), this.GetType());
 }
コード例 #7
0
        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
        }
コード例 #8
0
        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
        }
コード例 #9
0
 public override void TestCoverage()
 {
     // Alphabetical list, with FbxProperty at the top.
     base.TestCoverage();
     CoverageTester.TestCoverage(typeof(FbxPropertyBool), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyDouble), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyDouble3), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEBlendMode), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEGateFit), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEWrapMode), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEProjectionType), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyMarkerELook), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyNullELook), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyString), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyELightType), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEAreaLightShape), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEDecayType), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyFloat), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyEInheritType), this.GetType());
     CoverageTester.TestCoverage(typeof(FbxPropertyInt), this.GetType());
 }
コード例 #10
0
        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
        }
コード例 #11
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxManager), this.GetType());
 }
コード例 #12
0
        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
        }
コード例 #13
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxStatus), this.GetType());
 }
コード例 #14
0
 public virtual void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxAnimCurveDef), this.GetType());
 }
コード例 #15
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxIOPluginRegistry), this.GetType());
 }
コード例 #16
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxQuaternion), this.GetType());
 }
コード例 #17
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxVector4), this.GetType());
 }
コード例 #18
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxDouble4), this.GetType());
 }
コード例 #19
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(T), this.GetType());
 }
コード例 #20
0
 public void TestCoverage()
 {
     CoverageTester.TestCoverage(typeof(FbxMesh.BadBracketingException), this.GetType());
 }