コード例 #1
0
            public void LeavesNoEmptyCells()
            {
                LettersAndArrowsPuzzle puzzle = new LettersAndArrowsPuzzle(5);

                puzzle.FillEmptyCells();

                for (int row = 0; row < 5; row++)
                {
                    for (int column = 0; column < 5; column++)
                    {
                        var cell = puzzle.GetCellAtCoordinates(row, column);
                        Assert.AreNotEqual(' ', cell.Letter);
                        Assert.AreNotEqual(0, cell.Number);
                        Assert.AreNotEqual(Direction.Undefined, cell.Direction);
                    }
                }
            }
コード例 #2
0
            public void OHIO_CreatesExpectedFile()
            {
                const string HTML_DIRECTORY   = @"html\LettersAndArrows\";
                string       SOURCE_DIRECTORY = ConfigurationManager.AppSettings["SourceDirectory"] + "LettersAndArrows";

                LettersAndArrowsPuzzle puzzle = new LettersAndArrowsPuzzle("ohio", true, 4, 42);

                puzzle.FillEmptyCells();
                string generateHtml = puzzle.FormatHtmlForGoogle();

                File.WriteAllText(HTML_DIRECTORY + "actualExample1.html", generateHtml);
                var  expectedLines     = File.ReadAllLines(HTML_DIRECTORY + "expectedExample1.html");
                var  actualLines       = File.ReadAllLines(HTML_DIRECTORY + "actualExample1.html");
                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 + @"\expectedExample1.html", actualLines);
                }
                Assert.IsFalse(anyLinesDifferent, "Didn't expect any lines to be different.");
            }