public void CreateSelection() { selection = new TestSelection(); selection.Add(MakeTestNode("1", "Tom", "Passed")); selection.Add(MakeTestNode("2", "Dick", "Failed")); selection.Add(MakeTestNode("3", "Harry", "Passed")); }
private void Accumulate(TestSelection selection, TestNode testNode, TestNodePredicate predicate) { if (predicate(testNode)) selection.Add(testNode); else if (testNode.IsSuite) foreach (TestNode child in testNode.Children) Accumulate(selection, child, predicate); }
public bool RunTestBench() { foreach (string intro_string in _intro) { Console.WriteLine(intro_string); } ConsoleKeyInfo intro_selection = Console.ReadKey(); switch (intro_selection.Key) { case ConsoleKey.NumPad1: case ConsoleKey.D1: _selectionChoice = TestSelection.AllTests; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad2: case ConsoleKey.D2: _selectionChoice = TestSelection.AllTestsNoConfirm; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad3: case ConsoleKey.D3: _selectionChoice = TestSelection.GroupTests; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad4: case ConsoleKey.D4: _selectionChoice = TestSelection.GroupTestsNoConfirm; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad5: case ConsoleKey.D5: _selectionChoice = TestSelection.SingleUnitTests; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad6: case ConsoleKey.D6: _selectionChoice = TestSelection.SingleUnitTestsNoConfirm; while (DecideCompare()) { continue; } break; case ConsoleKey.NumPad7: case ConsoleKey.D7: case ConsoleKey.Escape: _selectionChoice = TestSelection.Exit; return(false); default: Console.WriteLine(Environment.NewLine + "Selection not understood." + Environment.NewLine); return(true); } #if TestBenchTwoPointOh if (_comparisonChoice == Comparison.Exit || _selectionChoice == TestSelection.Exit) #else if (_selectionChoice == TestSelection.Exit) #endif { return(false); } switch (_selectionChoice) { case TestSelection.AllTests: while (RunAllTests(true)) { continue; } break; case TestSelection.AllTestsNoConfirm: while (RunAllTests(false)) { continue; } Console.WriteLine("End of test, push a key to exit."); Console.ReadKey(); break; case TestSelection.GroupTests: while (RunGroupTests(true, false)) { continue; } break; case TestSelection.GroupTestsNoConfirm: while (RunGroupTests(false, false)) { continue; } Console.WriteLine("End of test, push a key to exit."); Console.ReadKey(); break; case TestSelection.SingleUnitTests: while (RunGroupTests(true, true)) { continue; } break; case TestSelection.SingleUnitTestsNoConfirm: while (RunGroupTests(false, true)) { continue; } Console.WriteLine("End of test, push a key to exit."); Console.ReadKey(); break; default: Console.WriteLine(Environment.NewLine + "Selection not understood." + Environment.NewLine); return(true); } return(false); }
public TestSelection Select(TestNodePredicate predicate, Comparison<TestNode> comparer) { var selection = new TestSelection(); Accumulate(selection, this, predicate); if (comparer != null) selection.Sort(comparer); return selection; }