// ReSharper disable IdentifierTypo // ReSharper disable StringLiteralTypo public void ThreeWords_ReturnsExpectedResults() { Anacrostic anacrostic = new Anacrostic("whichzonepretty"); // ReSharper restore StringLiteralTypo // ReSharper restore IdentifierTypo anacrostic.FindNextWord(); anacrostic.RemoveWord("which"); anacrostic.RemoveWord("zone"); anacrostic.RemoveWord("pretty"); Assert.AreEqual("", anacrostic.RemainingLetters()); Assert.AreEqual( @"clue for which clue for zone W H I C H Z O N E A1 A2 A3 A4 A5 B6 B7 B8 B9 clue for pretty P R E T T Y C10 C11 C12 C13 C14 C15 ", anacrostic.WordsFormattedForGoogleDocs()); Assert.AreEqual( @"A1A2A3A4A5B6", anacrostic.EncodedPhrase); }
public void IgnoresWords() { Anacrostic anacrostic = new Anacrostic("keep"); anacrostic.IgnoreWord("keep"); Assert.AreEqual("peek", anacrostic.FindNextWord()); }
public void SpecificPuzzleLength_SetsCorrectLineLength(int puzzleLength, int expectedLineLength) { string puzzlePhrase = new string('a', puzzleLength); Anacrostic anacrostic = new Anacrostic(puzzlePhrase); Assert.AreEqual(expectedLineLength, anacrostic.LineLength, $"Unexpected Line Length for puzzle phrase of length {puzzleLength}"); }
public void WHICH_FindsWord() { // ReSharper disable StringLiteralTypo Anacrostic anacrostic = new Anacrostic("whic h"); // ReSharper restore StringLiteralTypo Assert.AreEqual("which", anacrostic.FindNextWord()); }
public void SimpleExample_FindsKEEPS() { // ReSharper disable StringLiteralTypo Anacrostic anacrostic = new Anacrostic("kbpmmurrhhstttttteeee"); // ReSharper restore StringLiteralTypo anacrostic.WordsFoundSoFar.Add("there"); Assert.AreEqual("keeps", anacrostic.FindNextWord()); }
public void WHICH_FindsWord() { Anacrostic anacrostic = new Anacrostic("which"); anacrostic.RemoveWord("which"); for (char letter = 'a'; letter <= 'z'; letter++) { Assert.AreEqual(0, anacrostic.Remaining(letter)); } }
public void Multiples() { Anacrostic anacrostic = new Anacrostic("aaz"); Assert.AreEqual(2, anacrostic.Remaining('a')); Assert.AreEqual(1, anacrostic.Remaining('z')); for (char letter = 'b'; letter < 'z'; letter++) { Assert.AreEqual(0, anacrostic.Remaining(letter)); } }
public void CreatesListOfLetters() { Anacrostic anacrostic = new Anacrostic("az"); Assert.AreEqual(1, anacrostic.Remaining('a')); Assert.AreEqual(1, anacrostic.Remaining('z')); for (char letter = 'b'; letter < 'z'; letter++) { Assert.AreEqual(0, anacrostic.Remaining(letter)); } }
public void First56Numbers_SetsCorrectLineLength() { for (int puzzleLength = 1; puzzleLength <= 56; puzzleLength++) { string puzzlePhrase = new string('a', puzzleLength); Anacrostic anacrostic = new Anacrostic(puzzlePhrase); int actualLineLength = anacrostic.LineLength; if (actualLineLength == puzzleLength) { continue; } Assert.LessOrEqual(actualLineLength, 14, "Line length should be 14 or less."); Assert.LessOrEqual(8, actualLineLength, "Line length should be 9 or more."); } }
//[Ignore("Takes more than 3 seconds.")] //Takes more than 3 seconds, but covers most of the class. // ReSharper disable IdentifierTypo // ReSharper disable StringLiteralTypo public void WHICHZ_ReturnsExpectedResults() { Anacrostic anacrostic = new Anacrostic("whichZ".ToLowerInvariant()); // ReSharper restore StringLiteralTypo // ReSharper restore IdentifierTypo anacrostic.FindNextWord(); anacrostic.RemoveWord("which"); Assert.AreEqual("z", anacrostic.RemainingLetters()); Assert.AreEqual( @"clue for which clue for z W H I C H Z A1 A2 A3 A4 A5 B6 ", anacrostic.WordsFormattedForGoogleDocs()); Assert.AreEqual( @"which A1 A2 A3 A4 A5 z B6 ", anacrostic.WordsWithNumberedBlanks()); }
public void FindsThreeLetterWords() { Anacrostic anacrostic = new Anacrostic("m om"); Assert.AreEqual("mom", anacrostic.FindNextWord()); }
public void FourLetterExample_FindsPEEK() { Anacrostic anacrostic = new Anacrostic("keep"); Assert.AreEqual("peek", anacrostic.FindNextWord()); }
public void WillNotFindWordWithRepeatedLetters_IfNotEnoughLettersRemain() { Anacrostic anacrostic = new Anacrostic("pule"); Assert.AreEqual(null, anacrostic.FindNextWord()); }
public void RatchetAndClank_ReturnsExpectedResult(bool includeSolution) { const string HTML_DIRECTORY = @"html\Anacrostics\"; string SOURCE_DIRECTORY = ConfigurationManager.AppSettings["SourceDirectory"] + "Anacrostics"; Anacrostic anacrostic = new Anacrostic("Ratchet and Clank"); anacrostic.RemoveWord("talk"); anacrostic.RemoveWord("ran"); anacrostic.RemoveWord("catch"); anacrostic.RemoveWord("end"); foreach (var clue in anacrostic.Puzzle.Clues) { StringBuilder builder = new StringBuilder(); foreach (var letter in clue.Letters) { builder.Append(letter.ActualLetter); } var currentWord = builder.ToString(); switch (currentWord) { case "talk": clue.CustomizedClue = "Speak"; break; case "ran": clue.CustomizedClue = "Competed in a foot race"; break; case "catch": clue.CustomizedClue = "I'll throw the ball, and you _____ it."; break; case "end": clue.CustomizedClue = "The last two words in most stories are 'The ___'."; break; default: Console.WriteLine($"No clue yet for {currentWord}"); break; } } Assert.AreEqual("", anacrostic.RemainingLetters()); string generatedHtml = anacrostic.FormatHtmlForGoogle(includeSolution); CollectionAssert.AreEquivalent(anacrostic.EnumerateCellValues(), anacrostic.EnumerateCellValuesReplacement()); var actualFileName = "actualExample2.html"; if (includeSolution) { actualFileName = "actualExampleWithSolution2.html"; } File.WriteAllText(HTML_DIRECTORY + actualFileName, generatedHtml); var expectedFileName = "expectedExample2.html"; if (includeSolution) { expectedFileName = "expectedExampleWithSolution2.html"; } string[] expectedLines = new[] { " " };// need to have something to be different from generated file. if (File.Exists(HTML_DIRECTORY + expectedFileName)) { expectedLines = File.ReadAllLines(HTML_DIRECTORY + expectedFileName); } var actualLines = File.ReadAllLines(HTML_DIRECTORY + actualFileName); bool anyLinesDifferent = false; for (var index = 0; index < expectedLines.Length; index++) { string expectedLine = expectedLines[index]; string actualLine = "End of file already reached."; if (index >= 0 && actualLines.Length > index) { actualLine = actualLines[index]; } if (expectedLine != actualLine) { anyLinesDifferent = true; Console.WriteLine($"Expected Line {index}:{expectedLine}"); Console.WriteLine($" Actual Line {index}:{expectedLine}"); } } if (anyLinesDifferent) { Console.WriteLine("Updating source file. Will show up as a difference in source control."); File.WriteAllLines(SOURCE_DIRECTORY + $@"\{expectedFileName}", actualLines); } Assert.IsFalse(anyLinesDifferent, "Didn't expect any lines to be different."); }
public void NonWords_FindsNothing(string phrase) { Anacrostic anacrostic = new Anacrostic(phrase); Assert.IsNull(anacrostic.FindNextWord()); }
public void FindsLint() { Anacrostic anacrostic = new Anacrostic("lin t"); Assert.AreEqual("lint", anacrostic.FindNextWord()); }