コード例 #1
0
        public void MoveEast_Should_Move_Current_Coordinate_Appropriately(int currentX, int currentY, bool checkLegality, int expectedX, int expectedY)
        {
            var context = new MazeCrawlerContext
            {
                Start         = new Coordinates(currentX, currentY),
                NavigationMap = _moveMap,
                Coordinator   = Substitute.For <IMazeCrawlerCoordinator>()
            };
            var crawler = new MazeCrawler(context);

            crawler.MoveEast(checkLegality);

            crawler.CurrentX.Should().Be(expectedX);
            crawler.CurrentY.Should().Be(expectedY);
        }
コード例 #2
0
        public void MoveEast_Should_Default_Unsupplied_Parameter_To_True(int x, int expectedX)
        {
            var context = new MazeCrawlerContext
            {
                Start         = new Coordinates(x, 0),
                NavigationMap = new Map(new char[][]
                {
                    new [] { Map.EMPTY, Map.EMPTY }
                }),
                Coordinator = Substitute.For <IMazeCrawlerCoordinator>()
            };
            var crawler = new MazeCrawler(context);

            crawler.MoveEast();

            crawler.CurrentX.Should().Be(expectedX);
        }
コード例 #3
0
        public void MoveEast_Should_Not_BackTrack()
        {
            var context = new MazeCrawlerContext
            {
                Start         = new Coordinates(0, 0),
                NavigationMap = new Map(new char[][]
                {
                    new [] { Map.EMPTY, Map.EMPTY }
                }),
                Coordinator = Substitute.For <IMazeCrawlerCoordinator>()
            };
            var crawler = new MazeCrawler(context);

            crawler.MoveEast();
            crawler.MoveWest();

            crawler.CanMove(Direction.West).Should().BeFalse();
            crawler.CurrentX.Should().Be(1);
        }
コード例 #4
0
        public void TraceSteps_Should_Return_Correctly(int startX, int startY, bool checkLegality, string expected)
        {
            var context = new MazeCrawlerContext
            {
                Start         = new Coordinates(startX, startY),
                Destination   = new Coordinates(5, 5),
                NavigationMap = _canMoveMap,
                Coordinator   = Substitute.For <IMazeCrawlerCoordinator>()
            };
            var crawler = new MazeCrawler(context);

            crawler.MoveEast(checkLegality)
            .MoveNorth(checkLegality)
            .MoveWest(checkLegality)
            .MoveWest(checkLegality)
            .MoveSouth(checkLegality);

            crawler.TraceSteps().Should().Be(expected);
        }