Esempio n. 1
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);
        }
Esempio n. 2
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());
        }
Esempio n. 3
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);
        }
Esempio n. 4
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());
        }
Esempio n. 5
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);
        }