public virtual IEnumerable <TestResult> Profile(ITestee testee, int count = Constants.DefaultRepetitionCount) { var testsets = GetProfilingTestSets(); foreach (var testset in testsets) { object actual = null; TimeSpan total = TimeSpan.Zero; for (var i = 0; i < count; i++) { var start = DateTime.UtcNow; actual = testee.Run(testset.Input); var end = DateTime.UtcNow; var diff = end - start; total += diff; } total /= count; var tr = new TestResult { TestSet = testset, Actual = actual, Passed = false, // not cared Elapse = total }; yield return(tr); } }
public virtual IEnumerable <string> TestAndShowResults(ITestee testee) { var trs = Test(testee); var i = 1; foreach (var tr in trs) { if (tr.Passed) { yield return($"Test {i++} passed, taking {tr.Elapse.TotalSeconds} second(s)."); } else { yield return($"Test {i++} failed, taking {tr.Elapse.TotalSeconds} second(s), '{ResultToString(tr.TestSet.ExpectedOutput)}' expected but '{ResultToString(tr.Actual)}' returned."); yield break; } } }
public virtual IEnumerable <TestResult> Test(ITestee testee) { var testsets = GetTestSets(); foreach (var testset in testsets) { var start = DateTime.UtcNow; var actual = testee.Run(testset.Input); var end = DateTime.UtcNow; var tr = new TestResult { TestSet = testset, Actual = actual, Passed = ResultsEqual(testset.ExpectedOutput, actual), Elapse = end - start }; yield return(tr); } }
public TestResult(ITest test, ITestee parser) { Test = test; Parser = parser; Durations = new List<TimeSpan>(); }
public TestResult(ITest test, ITestee parser) { Test = test; Parser = parser; Durations = new List <TimeSpan>(); }