private static void Print <TResult>(Func <TResult> result, object[] input) { Console.WriteLine("TEST {0}", Value(input)); Stopwatch stopwatch = Stopwatch.StartNew(); TResult answer; try { answer = result(); } catch (Exception ex) { Console.Write(" "); using (ConsoleIndicator.Exception()) { Console.Write("!!! EXCEPTION !!!"); } Console.WriteLine(" {0}", ex.Message); return; } stopwatch.Stop(); Console.Write(" "); using (ConsoleIndicator.Result()) { Console.Write("RETURNED"); } Console.WriteLine(" [{0}ms] ANSWER {1}", stopwatch.ElapsedMilliseconds, Value(answer)); }
private static void Check <TResult>(Func <TResult> result, object[] input, TResult expected) { Console.WriteLine("TEST {0}", Value(input)); Stopwatch stopwatch = Stopwatch.StartNew(); TResult answer; try { answer = result(); } catch (Exception ex) { Console.Write(" "); using (ConsoleIndicator.Exception()) { Console.Write("!!! EXCEPTION !!!"); } Console.WriteLine(" {0}", ex.Message); return; } stopwatch.Stop(); if (CheckResult(answer, expected)) { Console.Write(" "); using (ConsoleIndicator.Passed()) { Console.Write("PASSED"); } } else { Console.Write(" "); using (ConsoleIndicator.Failed()) { Console.Write("!!! FAILED !!!"); } } Console.WriteLine(" [{0}ms] ANSWER {1} EXPECTED {2}", stopwatch.ElapsedMilliseconds, Value(answer), Value(expected)); }