public void TestInvalidBoardPosition()
        {
            // arrange
            ToyBoard.ToyBoard squareBoard = new ToyBoard.ToyBoard(5, 5);
            Position          position    = new Position(6, 6);

            // act
            var result = squareBoard.IsValidPosition(position);

            // assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 2
0
        public void TestInvalidBehaviourPlace()
        {
            // arrange
            IToyBoard    squareBoard = new ToyBoard.ToyBoard(5, 5);
            IInputParser inputParser = new InputParser();
            IToyRobot    robot       = new ToyRobot();
            var          simulator   = new Behaviours.Behaviour(robot, squareBoard, inputParser);

            // act
            simulator.ProcessCommand("PLACE 9,7,EAST".Split(' '));

            // assert
            Assert.IsNull(robot.Position);
        }
Ejemplo n.º 3
0
        public void TestValidBehaviourMove()
        {
            // arrange
            IToyBoard    squareBoard = new ToyBoard.ToyBoard(5, 5);
            IInputParser inputParser = new InputParser();
            IToyRobot    robot       = new ToyRobot();
            var          simulator   = new Behaviours.Behaviour(robot, squareBoard, inputParser);

            // act
            simulator.ProcessCommand("PLACE 3,2,SOUTH".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));

            // assert
            Assert.AreEqual("Output: 3,1,SOUTH", simulator.GetReport());
        }
Ejemplo n.º 4
0
        public void TestValidBehaviourPlace()
        {
            // arrange
            IToyBoard    squareBoard = new ToyBoard.ToyBoard(5, 5);
            IInputParser inputParser = new InputParser();
            IToyRobot    robot       = new ToyRobot();
            var          simulator   = new Behaviours.Behaviour(robot, squareBoard, inputParser);

            // act
            simulator.ProcessCommand("PLACE 1,4,EAST".Split(' '));

            // assert
            Assert.AreEqual(1, robot.Position.X);
            Assert.AreEqual(4, robot.Position.Y);
            Assert.AreEqual(Direction.East, robot.Direction);
        }
Ejemplo n.º 5
0
        public void TestInvalidBehaviourMove()
        {
            // arrange
            IToyBoard    squareBoard = new ToyBoard.ToyBoard(5, 5);
            IInputParser inputParser = new InputParser();
            IToyRobot    robot       = new ToyRobot();
            var          simulator   = new Behaviours.Behaviour(robot, squareBoard, inputParser);

            // act
            simulator.ProcessCommand("PLACE 2,2,NORTH".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));
            // if the robot goes out of the board it ignores the command
            simulator.ProcessCommand("MOVE".Split(' '));

            // assert
            Assert.AreEqual("Output: 2,4,NORTH", simulator.GetReport());
        }
Ejemplo n.º 6
0
        public void TestValidBehaviourReport()
        {
            // arrange
            IToyBoard    squareBoard = new ToyBoard.ToyBoard(5, 5);
            IInputParser inputParser = new InputParser();
            IToyRobot    robot       = new ToyRobot();
            var          simulator   = new Behaviours.Behaviour(robot, squareBoard, inputParser);

            // act
            simulator.ProcessCommand("PLACE 3,3,WEST".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));
            simulator.ProcessCommand("LEFT".Split(' '));
            simulator.ProcessCommand("MOVE".Split(' '));
            var output = simulator.ProcessCommand("REPORT".Split(' '));

            // assert
            Assert.AreEqual("Output: 1,2,SOUTH", output);
        }