public void BetweenEdgeTest()
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            for (int x = 0; x < hexBoard.Size; x++)
            {
                for (int y = 0; y < hexBoard.Size; y++)
                {
                    Location testLoc = new Location(x, y);

                    Cell[] resultX = hexBoard.BetweenEdge(testLoc, true);

                    if (y == 1)
                    {
                        // second or second-last row
                        if (x < hexBoard.Size - 1)
                        {
                            Assert.AreEqual(2, resultX.Length, testLoc.ToString());
                        }
                    }
                    else if (y == hexBoard.Size - 2)
                    {
                        // second or second-last row
                        if (x > 0)
                        {
                            Assert.AreEqual(2, resultX.Length, testLoc.ToString());
                        }
                    }
                    else
                    {
                        Assert.AreEqual(0, resultX.Length, testLoc.ToString());
                    }

                    Cell[] resultY = hexBoard.BetweenEdge(testLoc, false);

                    if (x == 1)
                    {
                        // second or second-last row
                        if (y < hexBoard.Size - 1)
                        {
                            Assert.AreEqual(2, resultY.Length, testLoc.ToString());
                        }
                    }
                    else if (x == hexBoard.Size - 2)
                    {
                        // second or second-last row
                        if (y > 0)
                        {
                            Assert.AreEqual(2, resultY.Length, testLoc.ToString());
                        }
                    }
                    else
                    {
                        Assert.AreEqual(0, resultY.Length, testLoc.ToString());
                    }
                }
            }
        }
Example #2
0
 public void ToStringReturnsCorrectString()
 {
     Location location = new Location(12, 33);
     Assert.AreEqual("12,33", location.ToString());
 }