private void do_startup() { // this includes the executable as s[0], which we don't want string[] args = Environment.GetCommandLineArgs(); Debug.Assert(args.Length >= 2, "Unexpected number of args. args[0]=exe, args[1]=dll to test"); string[] new_args = args.Skip(2).ToArray(); if (runUnitTest) { try { // Setup the unit test case unitTestMethod = UnitTestsUtil.FindUnitTestMethodByName(testAssembly, unitTestMethodName, new_args.Length); unitTestCase = UnitTestsUtil.CreateUnitTestCase(unitTestMethod, CreateTestContext(), new_args); } catch (Exception ex) { ReportErrorAndExit(ex.Message, ChessExitCode.TestFailure, false, ex); } } else { // Use the ChessTest.Startup method try { if (startup != null) { bool ret = (bool)startup.Invoke(null, new Object[] { new_args }); if (!ret) { ReportErrorAndExit(testclass + ".Startup returned false.", ChessExitCode.TestFailure, false, null); } } GC.Collect(); GC.WaitForPendingFinalizers(); manager.RunFinalizers(); } catch (Exception ex) { if (ex is TargetInvocationException) { ex = ((TargetInvocationException)ex).InnerException; } string message = testclass + ".Startup threw unexpected exception: " + ex.GetType(); ReportErrorAndExit(message, ChessExitCode.UnitTestException, false, ex); } } }