コード例 #1
0
        public void RoverEngine_MoveBack_From11N_To10N()
        {
            var engine = new RoverEngine(1, 1, EDirection.N, _gridHeight, _gridWidth, _mockObstacleDetector.Object);

            var moveResult = engine.MoveBack();

            Assert.AreEqual(1, moveResult.Position.X);
            Assert.AreEqual(0, moveResult.Position.Y);
            Assert.AreEqual(EDirection.N, moveResult.Position.Direction);
        }
コード例 #2
0
        public void RoverEngine_MoveBack_W_ObstacleDetected_ReportObstacle()
        {
            _mockObstacleDetector.Setup(m => m.CanMove(2, 1)).Returns(false);

            var engine = new RoverEngine(1, 1, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object);

            var moveResult = engine.MoveBack();

            Assert.AreEqual(1, moveResult.Position.X);
            Assert.AreEqual(1, moveResult.Position.Y);
            Assert.AreEqual(EDirection.W, moveResult.Position.Direction);
            Assert.IsTrue(moveResult.IsObstacleDetected);
        }
コード例 #3
0
        public void RoverEngine_WrapWest_MoveBack150_From15W_To51_5W()
        {
            var engine = new RoverEngine(1, 5, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object);

            for (int i = 0; i < 150; i++)
            {
                engine.MoveBack();
            }

            var newPosition = engine.GetPosition();

            Assert.AreEqual(51, newPosition.X);
            Assert.AreEqual(5, newPosition.Y);
            Assert.AreEqual(EDirection.W, newPosition.Direction);
        }
コード例 #4
0
        public void RoverEngine_WrapWest_MoveBack100_ArriveAtSameSpot()
        {
            var engine = new RoverEngine(0, 0, EDirection.W, _gridHeight, _gridWidth, _mockObstacleDetector.Object);

            for (int i = 0; i < 100; i++)
            {
                engine.MoveBack();
            }

            var newPosition = engine.GetPosition();

            Assert.AreEqual(0, newPosition.X);
            Assert.AreEqual(0, newPosition.Y);
            Assert.AreEqual(EDirection.W, newPosition.Direction);
        }