Пример #1
0
        public void TestAdjacentCell()
        {
            var pf = new Playfield(3, 3);

            for (int c = 0; c < pf.NumCellColumns; c++)
            {
                for (int r = 0; r < pf.NumCellRows; r++)
                {
                    var  currCell = pf.Cells[c][r];
                    Cell expected = pf.IsValid(c - 1, r) ? pf.Cells[c - 1][r] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.Left));
                    expected = pf.IsValid(c + 1, r) ? pf.Cells[c + 1][r] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.Right));
                    expected = pf.IsValid(c, r - 1) ? pf.Cells[c][r - 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.Up));
                    expected = pf.IsValid(c, r + 1) ? pf.Cells[c][r + 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.Down));
                    expected = pf.IsValid(c - 1, r - 1) ? pf.Cells[c - 1][r - 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.UpLeft));
                    expected = pf.IsValid(c + 1, r - 1) ? pf.Cells[c + 1][r - 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.UpRight));
                    expected = pf.IsValid(c - 1, r + 1) ? pf.Cells[c - 1][r + 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.DownLeft));
                    expected = pf.IsValid(c + 1, r + 1) ? pf.Cells[c + 1][r + 1] : null;
                    Assert.AreEqual(expected, pf.AdjacentCell(currCell, Playfield.Position.DownRight));
                }
            }
        }