static bool RunTestCase(QXDMAutomation.TestCase testCase, string functionName, AutomationWindow automationWindow, uint port) { bool usesComPort = testCase._requiresComPort; // Print to log string msg = "< RUNNING TEST CASE: " + functionName.ToUpper() + " >"; LogEverywhere(""); for (int i = 0; i < msg.Length; i++) { Console.Write("\\"); logFile.Write("\\"); } LogEverywhere("\n" + msg); string errorMessage = "\t[ERROR] Test case \"" + functionName + "\" failed: "; string successMessage = "\t[PASS] Test case \"" + functionName + "\" succeeded"; // Run setup function if (testCase._setup != null && testCase._setup(automationWindow) == false) { logFile.WriteLine(errorMessage + "Setup function failed"); return(false); } // Set up COM stuff if needed if (usesComPort == true) { if (port != 0) { if (automationWindow.SetComPort(port) == true) { if (automationWindow.GetServerState() == 2) { Console.WriteLine("Connected to port: {0}", port); } else { logFile.WriteLine(errorMessage + "Error connecting to port: " + port); return(false); } } else { logFile.WriteLine(errorMessage + "SetComPort Failed - port: " + port + " message: " + automationWindow.GetLastErrorString()); return(false); } } else { logFile.WriteLine(errorMessage + "Requires a connection"); return(false); } } // Run exec function if (testCase._exec != null && testCase._exec(automationWindow) == false) { logFile.WriteLine(errorMessage + "Exec function failed"); return(false); } // Disconnect the port if in use if (usesComPort == true) { automationWindow.SetComPort(0); } // Run teardown (cleanup) function if (testCase._teardown != null && testCase._teardown(automationWindow) == false) { logFile.WriteLine(errorMessage + "Teardown function failed"); return(false); } logFile.WriteLine(successMessage); return(true); }