public void RunTests() { List <RawTestCase> testCases = LoadTestCases(); int width = 10 + 28 * tasks.Count + 2; if (width < Console.WindowWidth) { Console.BufferWidth = Console.WindowWidth = width; } else { Console.WindowWidth = Console.BufferWidth = width; } Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(group); Console.Write($"{"",10}"); foreach (ITestTask task in tasks) { Console.Write($"| {task.Name(),25} "); } Console.WriteLine("|"); foreach (RawTestCase rawTestCase in testCases) { testCase.Prepare(rawTestCase.Given, rawTestCase.Expect); Console.Write($"Test: #{rawTestCase.TestCaseNumer,2} "); List <(ITestTask, Task <(double, bool, bool)>)> runTests = new List <(ITestTask, Task <(double, bool, bool)>)>(); CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); //CancellationTokenSource tokenSource = new CancellationTokenSource(); foreach (ITestTask task in tasks) { runTests.Add((task, RunTask(task, testCase, tokenSource.Token))); } foreach ((ITestTask task, Task <(double, bool, bool)> asyncTask) in runTests) { asyncTask.Wait(); (double duration, bool exception, bool canceled) = asyncTask.Result; bool success = !exception && task.Compare(testCase); Console.Write("|"); if (exception) { Console.BackgroundColor = canceled ? ConsoleColor.Yellow : ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Black; } Console.Write($" {success,5} - {duration,17:g8} "); if (exception) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Gray; } } Console.WriteLine("|"); } Console.WriteLine(""); }