public void DefaultPattern_DefaultTentConfiguration_ReturnsExpectedLetters() { WordTents tents = new WordTents(); tents.PatternOverrideForTests = new WordTents.Pattern() { Top = WordTents.PatternInstruction.RealLetter, Middle = WordTents.PatternInstruction.FakeLetter, Bottom = WordTents.PatternInstruction.CutSpace, }; tents.FakeLetterOverrideForTests = 'f'; tents.TentConfiguration = "tmb"; tents.Words = InitialTentWords; tents.MakeTents(); var lettersToDisplay = tents.GetLettersToDisplay(); Assert.AreEqual(8, lettersToDisplay.Count, "Expected 8 lines of text"); for (int index = 0; index < 4; index++) { Assert.AreEqual(BACK_OF_REAL_LETTER.ToUpperInvariant() + BACK_OF_FAKE_LETTER.ToUpperInvariant() + BACK_OF_CUT_SPACE.ToUpperInvariant(), lettersToDisplay[index], "One of the first four lines was incorrect."); } for (int index = 4; index < 8; index++) { Assert.AreEqual(FRONT_OF_REAL_LETTER.ToLowerInvariant() + FRONT_OF_FAKE_LETTER.ToLowerInvariant() + FRONT_OF_CUT_SPACE.ToLowerInvariant(), lettersToDisplay[index], "One of the first four lines was incorrect."); } }
[TestCase(true, "most", "cars", "TURN", "LEFT")] //MOST CARS TURN LEFT @whatseplaying /* * Home Away from Home * Just Take Your Time * They Play With Fire * Wear Mask Over Nose * * THEY SAID ZERO RATS Jusiv_ * FISH FOOD TACO TIME Jusiv_ * THIS CLUE WILL HELP whatseplaying * */ public void WithSpecialCharacter_ReturnsExpectedResult(bool includeSolution, string firstWord, string secondWord, string thirdWord, string fourthWord) { const string HTML_DIRECTORY = @"html\WordTents\"; string SOURCE_DIRECTORY = ConfigurationManager.AppSettings["SourceDirectory"] + "WordTents"; var puzzleRandomGeneratorSeed = 42 + firstWord[0] + firstWord[1]; var puzzle = new WordTents(); puzzle.RandomGeneratorSeed = puzzleRandomGeneratorSeed; puzzle.Words = new List <string> { firstWord, secondWord, thirdWord.ToUpperInvariant(), fourthWord.ToUpperInvariant() }; puzzle.MakeTents(); string generatedHtml = puzzle.FormatHtmlForGoogle(includeSolution); var actualFileName = $"actualExample_{firstWord}.html"; if (includeSolution) { actualFileName = $"actualExampleWithSolution_{firstWord}.html"; } File.WriteAllText(HTML_DIRECTORY + actualFileName, generatedHtml); var expectedFileName = $"expectedExample_{firstWord}.html"; if (includeSolution) { expectedFileName = $"expectedExampleWithSolution_{firstWord}.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.Equals(actualLine, StringComparison.InvariantCultureIgnoreCase)) { anyLinesDifferent = true; Console.WriteLine($"Expected Line {index}:{expectedLine}"); Console.WriteLine($" Actual Line {index}:{actualLine}"); } } 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."); }