Пример #1
0
        public void Turnright_TableTop5Into5RobotTurnedRightFourTimesSameFacing_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 rightCommand = new TurnRightCommand(tr);

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

            //assert
            Assert.AreEqual(tr.robotDirection, Facing.NORTH);
        }
        public void Test_Execute()
        {
            _piece.SightDirection = Direction.North;

            _command.Execute();
            Assert.AreEqual(Direction.East, _piece.SightDirection);

            _command.Execute();
            Assert.AreEqual(Direction.South, _piece.SightDirection);

            _command.Execute();
            Assert.AreEqual(Direction.West, _piece.SightDirection);

            _command.Execute();
            Assert.AreEqual(Direction.North, _piece.SightDirection);
        }
        public void West_direction_rover()
        {
            var plateau = new Plateau(new Point(5, 5));
            var rover   = new Rover(plateau, new Location(new Point(1, 2), CardinalDirection.West));
            RoboticRoverCommand command = new TurnRightCommand(rover);

            command.Execute();

            rover.Location.CardinalDirection.Should().Be(CardinalDirection.North);
        }
Пример #4
0
        public void Turnright_TableTopFiveIntoFiveRobotNotPlacedBeforeTurnLeft()
        {
            //arrange
            TableTop          tt        = new TableTop(5, 5);
            ToyRobot          tr        = new ToyRobot();
            ICommandInterface turnRight = new TurnRightCommand(tr);

            //act
            turnRight.Execute();
            //assert
            Assert.IsFalse(tr.isRobotPlaced);
        }
Пример #5
0
        public void Turn_Right_Command_Should_Change_Heading_Accordingly(Heading input, Heading expected)
        {
            //arrange
            var      random   = new Random();
            var      location = new Location(random.Next(), random.Next(), input);
            ICommand command  = new TurnRightCommand(location);

            //act
            command.Execute();

            //assert
            Assert.Equal(location.GetHeading(), expected);
        }
        public void Test_TurnRightCommand()
        {
            var plateau    = new Plateau(5, 5);
            var coordinate = new Coordinate(1, 2);
            var direction  = DirectionParser.GetDirection('N');
            var rover      = new MarsRover(plateau, coordinate, direction);

            var moveCommand = new TurnRightCommand();

            moveCommand.Execute(rover);

            Assert.AreEqual("1 2 E", rover.GetCurrentLocation());
        }
Пример #7
0
        public void Turnright_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 rightCommand = new TurnRightCommand(tr);

            //act
            rightCommand.Execute();

            //assert
            Assert.IsTrue(tr.isRobotPlaced);
        }