Beispiel #1
0
        private void get_entries(Type t)
        {
            MethodInfo mi = t.GetMethod("Startup");

            if (mi != null)
            {
                if (mi.IsStatic && mi.ReturnType == typeof(bool) &&
                    mi.GetParameters().Length == 1 &&
                    mi.GetParameters()[0].ParameterType == typeof(string[]))
                {
                    startup = mi;
                }
                else
                {
                    var msg = "Error: Startup function must be of form [public static bool " + testclass + ".Startup(string [])]";
                    ReportErrorAndExit(msg, ChessExitCode.ChessInvalidTest, false, null);
                }
            }

            mi = t.GetMethod("Run");
            if (mi != null)
            {
                if (mi.IsStatic && mi.ReturnType == typeof(bool) &&
                    mi.GetParameters().Length == 0)
                {
                    run = mi;
                }
                else
                {
                    var msg = "Error: Run function must be of form [public static bool " + testclass + ".Run()].";
                    ReportErrorAndExit(msg, ChessExitCode.ChessInvalidTest, false, null);
                }
            }

            mi = t.GetMethod("Shutdown");
            if (mi != null)
            {
                if (mi.IsStatic && mi.ReturnType == typeof(bool) && mi.GetParameters().Length == 0)
                {
                    shutdown = mi;
                }
                else
                {
                    var msg = "Error: Shutdown function must be of form [public static bool " + testclass + ".Shutdown()].";
                    ReportErrorAndExit(msg, ChessExitCode.ChessInvalidTest, false, null);
                }
            }

            mi = t.GetMethod("ChessOnErrorCallback");
            if (mi != null)
            {
                if (mi.IsStatic && mi.ReturnType == typeof(bool) &&
                    mi.GetParameters().Length == 2 &&
                    mi.GetParameters()[0].ParameterType == typeof(int) &&
                    mi.GetParameters()[1].ParameterType == typeof(string)
                    )
                {
                    onErrorCallback    = mi;
                    OnErrorCallbackDel = new MChessChess.OnErrorCallbackDelegate(OnErrorCallback);
                    MChessChess.QueueOnErrorCallback(OnErrorCallbackDel);
                }
                else
                {
                    var msg = "Error: ChessOnErrorCallback function must be of form [public static bool " + testclass + ".ChessOnErrorCallBack(int,string)].";
                    ReportErrorAndExit(msg, ChessExitCode.ChessInvalidTest, false, null);
                }
            }
        }