public void MovesSingleLine() { // ReSharper disable StringLiteralTypo AlphabetSoup puzzle = new AlphabetSoup { Solution = "abcdefghijklmnopqrstuvwxyz" }; // ReSharper restore StringLiteralTypo puzzle.GenerateLineAtIndex(0); puzzle.ScrambleLines(); bool foundSingleNonNullLine = false; foreach (string line in puzzle.Lines) { Console.WriteLine(line); if (foundSingleNonNullLine) //All other lines should be null. { Assert.IsNull(line); } else { if (!string.IsNullOrWhiteSpace(line)) { foundSingleNonNullLine = true; } } } }
private void ApplyTest(String input, string expected) { AlphabetSoup calculator = new AlphabetSoup(input); string result = calculator.GetResult(); Assert.AreEqual(expected, result); }
public void CreatesExpectedPuzzle() { AlphabetSoup puzzle = new AlphabetSoup(Repository); // ReSharper disable StringLiteralTypo const string SOLUTION = "greenredyellowpurpleorange"; // ReSharper restore StringLiteralTypo List <string> lines = puzzle.GeneratePuzzle(SOLUTION); Assert.AreEqual(26, lines.Count); StringBuilder builder = new StringBuilder(); foreach (string currentLine in lines) { string tabDelimitedLine = string.Join('\t'.ToString(), currentLine.ToCharArray()); builder.AppendLine(tabDelimitedLine); } var formattedPuzzle = builder.ToString(); Console.WriteLine(formattedPuzzle); for (int index = 0; index < 26; index++) { string line = lines[index]; string hiddenWord = AssertExactlyOneSubstringIsAWord(line); Console.WriteLine($"{line} {hiddenWord.ToUpper()}"); Assert.AreEqual(SOLUTION[index], line[0], "Expected first letter in the line to match the solution."); Assert.AreEqual((char)97 + index, line[3], "Expected the alphabet to be in the middle."); } }
public void Output_FitsExpectedFormat() { AlphabetSoup puzzle = new AlphabetSoup(Repository); string line = puzzle.GenerateSingleLine('a', 'b'); Assert.AreEqual(7, line.Length, "Expected 7 letters."); AssertExactlyOneSubstringIsAWord(line); }
public void PopulatesExpectedLine() { // ReSharper disable StringLiteralTypo AlphabetSoup puzzle = new AlphabetSoup { Solution = "abcdefghijklmnopqrstuvwxyz" }; // ReSharper restore StringLiteralTypo puzzle.GenerateLineAtIndex(0); Assert.AreEqual('a', puzzle.Lines[0][3], "Fourth character of this line should be 'a'"); }
public void ExampleThatStartsInSecondPosition() { AlphabetSoup puzzle = new AlphabetSoup(Repository) { RandomSeed = 1 }; // ReSharper disable StringLiteralTypo Assert.AreEqual("allayam", puzzle.GenerateSingleLine('a', 'a')); Assert.AreEqual("alabout", puzzle.GenerateSingleLine('a', 'b')); // ReSharper restore StringLiteralTypo }
public void CallTwice_GeneratesDifferentLines(StartPosition selectedPosition) { AlphabetSoup puzzle = new AlphabetSoup(Repository); string firstLine = puzzle.HideWordInLine("stuck", selectedPosition); Assert.AreEqual(7, firstLine.Length, "Expected 7 letters."); AssertExactlyOneSubstringIsAWord(firstLine); string secondLine = puzzle.HideWordInLine("stuck", selectedPosition); Assert.AreEqual(7, secondLine.Length, "Expected 7 letters."); AssertExactlyOneSubstringIsAWord(secondLine); Assert.AreNotEqual(firstLine, secondLine); }
public void SimpleTest_PutsWordInExpectedPosition() { AlphabetSoup puzzle = new AlphabetSoup(Repository); string line = puzzle.HideWordInLine("stuck", StartPosition.FirstPosition); Assert.AreEqual(7, line.Length, "Expected 7 letters."); Assert.AreEqual("stuck", line.Substring(0, 5), "Expected word in first position"); AssertExactlyOneSubstringIsAWord(line); line = puzzle.HideWordInLine("stuck", StartPosition.SecondPosition); Assert.AreEqual(7, line.Length, "Expected 7 letters."); Assert.AreEqual("stuck", line.Substring(1, 5), "Expected word in second position"); AssertExactlyOneSubstringIsAWord(line); line = puzzle.HideWordInLine("stuck", StartPosition.ThirdPosition); Assert.AreEqual(7, line.Length, "Expected 7 letters."); Assert.AreEqual("stuck", line.Substring(2, 5), "Expected word in third position"); AssertExactlyOneSubstringIsAWord(line); }
public static string AlphabetSoupTests(string str) { return(AlphabetSoup.AlphabetSoupMethod(str)); }
public void Default_UsesDefaultRepository() { AlphabetSoup puzzle = new AlphabetSoup(); Assert.IsNotNull(puzzle); }