static void StartTest(string filename) { var testLines = new List<string>(); string[] lines = File.ReadAllLines(filename); var tester = new WTest(lines); tester.RunTest(new WTest.PreActionDelegate(PreAction), new WTest.ActionResultDelegate(Report)); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Type 'exit' then press enter to close the program, or enter the name of another WTest script"); string command = Console.ReadLine().Trim().ToLower(); if (command != "exit") { Start(command); } }
/// <summary> /// Run the test script /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRun_Click(object sender, EventArgs e) { btnRun.Enabled = false; btnPause.Enabled = true; btnCancel.Enabled = true; pbProgress.Enabled = true; if (_testThread != null && _testThread.ThreadState == ThreadState.Suspended) { _testThread.Resume(); return; } tbOutput.Text = ""; tabs.SelectTab(1); // Do in another thread so the UI does not get sticky. _testThread = new Thread(delegate() { var test = new WTest(editor.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None)); test.TestProgress += TestProgress; test.RunTest(new WTest.ActionResultDelegate(WriteResult)); }); _testThread.SetApartmentState(ApartmentState.STA); _testThread.Start(); }