コード例 #1
0
        public void SetCurrentPosition_throws_exception_if_outside_bounds()
        {
            GridNavigator navigator = new GridNavigator(10, 10);

            Assert.Throws <ArgumentOutOfRangeException>(() => { navigator.SetCurrentPosition(-1, -1); });
            Assert.Throws <ArgumentOutOfRangeException>(() => navigator.SetCurrentPosition(11, 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => navigator.SetCurrentPosition(0, 11));
        }
コード例 #2
0
ファイル: MazeGenerator.cs プロジェクト: LissaRider/MazeTask
        // We need local copy of GridNavigator for each call of recursive func
        private GridNavigator GetGridNavigator(int x, int y)
        {
            var result = new GridNavigator(_cells.GetLength(0), _cells.GetLength(1));

            result.SetCurrentPosition(x, y);
            return(result);
        }
コード例 #3
0
        public void SetCurrentPosition_sets_position()
        {
            GridNavigator navigator = new GridNavigator(10, 10);

            navigator.SetCurrentPosition(1, 2);

            Assert.AreEqual(new Cell(1, 2), navigator.CurrentPosition);
        }
コード例 #4
0
        public void Neighbours_for_corner_cell_returns_only_available_neighbours()
        {
            GridNavigator navigator = new GridNavigator(10, 10);

            navigator.SetCurrentPosition(0, 0);

            Assert.AreEqual(2, navigator.Neighbours.Count);
            Assert.AreEqual(new Cell(1, 0), navigator.Neighbours[Direction.Right]);
            Assert.AreEqual(new Cell(0, 1), navigator.Neighbours[Direction.Down]);
        }
コード例 #5
0
        public void Neighbours_returns_all_neighbour_cells()
        {
            GridNavigator navigator = new GridNavigator(10, 10);

            navigator.SetCurrentPosition(5, 5);

            Assert.AreEqual(new Cell(4, 5), navigator.Neighbours[Direction.Left]);
            Assert.AreEqual(new Cell(6, 5), navigator.Neighbours[Direction.Right]);
            Assert.AreEqual(new Cell(5, 6), navigator.Neighbours[Direction.Down]);
            Assert.AreEqual(new Cell(5, 4), navigator.Neighbours[Direction.Up]);
        }