// 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 WHICH_FindsWord() { Anacrostic anacrostic = new Anacrostic("which"); anacrostic.RemoveWord("which"); for (char letter = 'a'; letter <= 'z'; letter++) { Assert.AreEqual(0, anacrostic.Remaining(letter)); } }
//[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 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."); }