public void RunTest() { testNumber++; bool actualErasable; int actualCrossoutsNumber, actualRemainderNumber; DateTime begin; TimeSpan elapsed; PrintTestInfo(); #if DEBUG Console.WriteLine(new string(testSequence)); #endif PrintMessage("Checking if sequence is erasable and getting crossout number..."); begin = DateTime.Now; try { actualErasable = CrossoutChecker.Erasable(testSequence, testPatterns, out actualCrossoutsNumber); } catch (Exception ex) { PrintImportant(String.Format("Unexpected exception: {0}", ex.Message)); return; } elapsed = DateTime.Now - begin; PrintMessage(String.Format("Elapsed time: {0}", elapsed)); PrintMessage("Getting minimum remainder number..."); begin = DateTime.Now; try { actualRemainderNumber = CrossoutChecker.MinimumRemainder(testSequence, testPatterns); } catch (Exception ex) { PrintImportant(String.Format("Unexpected exception: {0}", ex.Message)); return; } elapsed = DateTime.Now - begin; totalTime += elapsed; PrintMessage(String.Format("Elapsed time: {0}", elapsed)); try { CompareResult(expectedErasable, actualErasable, "Erasable"); CompareResult(expectedCrossoutsNumber, actualCrossoutsNumber, "Crossout number"); CompareResult(expectedRemainderNumber, actualRemainderNumber, "Remainder number"); } catch (Exception ex) { PrintImportant(ex.Message); Console.WriteLine(); return; } PrintImportant("Test passed successfully"); testSuccess++; Console.WriteLine(); }
public TestResult TestMinimumRemainder(out string message) { DateTime t1 = DateTime.Now; int x = CrossoutChecker_rozw.MinimumRemainder(sequence, patterns); if (minimumRemainder == null) { minimumRemainder = x; } TimeSpan ts = DateTime.Now - t1; int w = -1; TestResult ret = TestResult.OK; string msg = "OK"; Thread th = new Thread(() => { if (catchExceptions) { try { w = CrossoutChecker.MinimumRemainder(sequence, patterns); } catch (ThreadAbortException) { return; } catch (Exception) { ret = TestResult.Exception; msg = "Wyjatek!"; return; } } else { w = CrossoutChecker.MinimumRemainder(sequence, patterns); } if (w != minimumRemainder) { ret = TestResult.BadMinimumRemainder; msg = "BLAD: jest " + w.ToString() + " a powinno byc " + minimumRemainder.ToString(); } }); th.Start(); if (!th.Join((int)(ts.TotalMilliseconds * mercyConstant) + 50)) { ret = TestResult.Timeout; msg = "Timeout!"; th.Abort(); } th.Join(); message = msg; return(ret); }
public TestResult TestMinimumRemainder(out string message) { int w = -1; TestResult ret = TestResult.OK; string msg = "OK"; w = CrossoutChecker.MinimumRemainder(sequence, patterns); if (w != minimumRemainder) { ret = TestResult.BadMinimumRemainder; msg = "BLAD: jest " + w.ToString() + " a powinno byc " + minimumRemainder.ToString(); } message = msg; return(ret); }