public void Guess_NoQuotes_GivesUpWithoutTakingForever() { var sw = new Stopwatch(); sw.Start(); bool certain; Assert.AreEqual(QuoteSystem.Default, QuoteSystemGuesser.Guess(ControlCharacterVerseData.Singleton, MockedBookForQuoteSystem.GetMockedBooks(null), ScrVers.English, out certain)); sw.Stop(); Assert.IsTrue(sw.ElapsedMilliseconds < 5200, "Actual time (ms): " + sw.ElapsedMilliseconds); Assert.IsFalse(certain); }
private void RunTest(QuoteSystem quoteSystem, bool highlyConsistentData, bool includeSecondLevelQuotes, bool expectedCertain) { Console.WriteLine("Attempting to guess " + quoteSystem.Name + "(" + quoteSystem + ")"); var sw = new Stopwatch(); sw.Start(); bool certain; var guessedQuoteSystem = QuoteSystemGuesser.Guess(ControlCharacterVerseData.Singleton, MockedBookForQuoteSystem.GetMockedBooks(quoteSystem, highlyConsistentData, includeSecondLevelQuotes), ScrVers.English, out certain); sw.Stop(); Console.WriteLine(" took " + sw.ElapsedMilliseconds + " milliseconds."); if (expectedCertain) { Assert.AreEqual(quoteSystem, guessedQuoteSystem, "Expected " + quoteSystem.FirstLevel + ", but was " + guessedQuoteSystem.FirstLevel); Assert.IsTrue(certain, "Quote system was not guessed with sufficient certainty: " + quoteSystem.Name + "(" + quoteSystem + ")"); } else { Assert.AreEqual(quoteSystem, guessedQuoteSystem, "Expected " + quoteSystem + ", but was " + guessedQuoteSystem); } }