コード例 #1
0
        public void Move_TableTop5Into5Placed3Into3RobotMovedFiveTimesForward()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 3),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();

            ICommandInterface moveCommand = new MoveForwardCommand(tr, tt);

            //act
            moveCommand.Execute();
            moveCommand.Execute();
            moveCommand.Execute();
            moveCommand.Execute();
            moveCommand.Execute();


            //assert: actual/expected
            Assert.IsTrue(tr.RobotStillOnTableTop(tt));
        }
コード例 #2
0
        public void Turnleft_TableTop5Into5RobotTurnedLeftFourTimesSameFaing_IsTrue()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 4),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();
            ICommandInterface leftCommand = new TurnLeftCommand(tr);

            //act
            leftCommand.Execute();
            leftCommand.Execute();
            leftCommand.Execute();
            leftCommand.Execute();

            //assert
            Assert.AreEqual(tr.robotDirection, Facing.NORTH);
        }
コード例 #3
0
        public void Move_TableTopFiveIntoFiveAlreadyPlacedMovedTwiceForward()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 3),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();

            ICommandInterface moveCommand = new MoveForwardCommand(tr, tt);

            //act
            moveCommand.Execute();
            moveCommand.Execute();


            //assert: actual/expected
            Assert.AreEqual(tr.GetCurrentRobotPosition(), new ToyRobot(new Coordinate(3, 5), Facing.NORTH).GetCurrentRobotPosition());
        }
コード例 #4
0
        public void Place_TableTopFiveIntoFivePlaceCoordinatesToThreeIntoFourAreEqual()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 4),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            //act
            placeCommand.Execute();

            //assert
            Assert.AreEqual(tr.GetCurrentRobotPosition(), new ToyRobot(new Coordinate(3, 4), Facing.NORTH).GetCurrentRobotPosition());
        }
コード例 #5
0
        public void Place_TableTop5Into5PlaceCommandRobotNotPlaced()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 6),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            //act
            placeCommand.Execute();

            //assert
            Assert.IsFalse(tr.isRobotPlaced);
        }
コード例 #6
0
        public void ToyRobot_TableTop5Into5PlaceRobot3Into3AndRobotOnTableTopIsTrue()
        {
            //arrange
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 3),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            //act
            placeCommand.Execute();

            //assert
            Assert.IsTrue(tr.RobotStillOnTableTop(tt));
        }
コード例 #7
0
        public void Turnleft_TableTopFiveIntoFiveRobotIsPlacedBeforeMove()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 4),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();

            ICommandInterface leftCommand = new TurnLeftCommand(tr);

            //act
            leftCommand.Execute();

            //assert
            Assert.IsTrue(tr.isRobotPlaced);
        }
コード例 #8
0
        public void Turnright_TableTop5Into5RobotTurnedRightTwice()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(3, 3),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();
            ICommandInterface rightCommand = new TurnRightCommand(tr);

            //act
            rightCommand.Execute();
            rightCommand.Execute();


            //assert
            Assert.AreEqual(tr.robotDirection, Facing.SOUTH);
        }
コード例 #9
0
        public void Move_TableTop5Into5Placed2Into3RobotMovedOnceSameFacing()
        {
            //arrange
            TableTop     tt = new TableTop(5, 5);
            ToyRobot     tr = new ToyRobot();
            CommandModel cm = new CommandModel()
            {
                Command    = Command.PLACE,
                Coordinate = new Coordinate(2, 3),
                Facing     = Facing.NORTH
            };
            ICommandInterface placeCommand = new PlaceRobotCommand(cm, tr, tt);

            placeCommand.Execute();

            ICommandInterface moveCommand = new MoveForwardCommand(tr, tt);

            //act
            moveCommand.Execute();

            //assert: actual/expected
            // Assert.AreEqual(tr.GetCurrentRobotPosition(), new ToyRobot(new Coordinate(3, 5), Facing.NORTH).GetCurrentRobotPosition());
            Assert.AreEqual(tr.robotDirection, Facing.NORTH);
        }