Пример #1
0
            public void TwoLetters_PlacesExpectedCells()
            {
                const int SIZE = 3;
                LettersAndArrowsPuzzle puzzle = new LettersAndArrowsPuzzle(SIZE);

                puzzle.PlaceSolution("ab");

                var cellWithA = puzzle.GetCellAtCoordinates(0, 0);

                Assert.AreEqual('A', cellWithA.Letter);
                int offset = cellWithA.Number;

                Assert.AreNotEqual(0, offset);
                Direction directionForB = cellWithA.Direction;

                Assert.AreNotEqual(Direction.Undefined, directionForB);
                int expectedRowForB    = 0;
                int expectedColumnForB = 0;

                switch (directionForB)
                {
                case Direction.Down:
                    expectedRowForB += offset;
                    break;

                case Direction.Right:       //always goes down, so this isn't necessary.
                    expectedColumnForB += offset;
                    break;

                case Direction.Up:
                    throw new Exception("Starting at 0, 0, the next direction should not be up.");

                case Direction.Left:
                    throw new Exception("Starting at 0, 0, next direction should not be left.");
                }

                for (int row = 0; row < SIZE; row++)
                {
                    for (int column = 0; column < SIZE; column++)
                    {
                        if (row == 0 && column == 0)
                        {
                            continue;                          //all other cells should be empty.
                        }
                        if (row == expectedRowForB && column == expectedColumnForB)
                        {
                            LetterAndArrowCell actualCellWhereBShouldBe = puzzle.GetCellAtCoordinates(row, column);
                            Assert.AreEqual('B', actualCellWhereBShouldBe.Letter);
                            Assert.AreEqual(0, actualCellWhereBShouldBe.Number);
                            Assert.AreEqual(Direction.Undefined, actualCellWhereBShouldBe.Direction);
                        }
                        else
                        {
                            Assert.AreEqual(LetterAndArrowCell.EmptyCell, puzzle.GetCellAtCoordinates(row, column));
                        }
                    }
                }
            }
Пример #2
0
            // ReSharper disable IdentifierTypo
            public void ABCD_ReturnsExpectedGrid()
            // ReSharper restore IdentifierTypo
            {
                LettersAndArrowsPuzzle puzzle = new LettersAndArrowsPuzzle(2);

                // ReSharper disable StringLiteralTypo
                puzzle.PlaceSolution("abcd");
                // ReSharper restore StringLiteralTypo

                /*
                 * A D
                 * B C
                 */
                LetterAndArrowCell actualA = puzzle.GetCellAtCoordinates(0, 0);

                Assert.AreEqual('A', actualA.Letter);
                Assert.AreEqual(1, actualA.Number);
                Assert.AreEqual(Direction.Down, actualA.Direction);

                LetterAndArrowCell actualB = puzzle.GetCellAtCoordinates(1, 0);

                Assert.AreEqual('B', actualB.Letter);
                Assert.AreEqual(1, actualB.Number);
                Assert.AreEqual(Direction.Right, actualB.Direction);

                LetterAndArrowCell actualC = puzzle.GetCellAtCoordinates(1, 1);

                Assert.AreEqual('C', actualC.Letter);
                Assert.AreEqual(-1, actualC.Number);
                Assert.AreEqual(Direction.Up, actualC.Direction);

                LetterAndArrowCell actualD = puzzle.GetCellAtCoordinates(0, 1);

                Assert.AreEqual('D', actualD.Letter);
                Assert.AreEqual(0, actualD.Number);
                Assert.AreEqual(Direction.Undefined, actualD.Direction);
            }