Beispiel #1
0
    public void Turn_left_edge_case()
    {
        var robot = new RobotSimulator(Bearing.North, new Coordinate(0, 0));

        robot.TurnLeft();
        Assert.That(robot.Direction, Is.EqualTo(Bearing.West));
    }
    public void Turn_left_edge_case()
    {
        var robot = new RobotSimulator(Bearing.North, new Coordinate(0, 0));

        robot.TurnLeft();
        Assert.Equal(Bearing.West, robot.Bearing);
    }
Beispiel #3
0
    public void Rotates_the_robots_direction_90_degrees_counter_clockwise_changes_the_direction_from_west_to_south()
    {
        var sut = new RobotSimulator(Direction.West, new Coordinate(0, 0));

        sut.TurnLeft();
        Assert.Equal(Direction.South, sut.Direction);
    }
Beispiel #4
0
    public void Rotates_the_robots_direction_90_degrees_counter_clockwise_does_not_change_the_position()
    {
        var sut = new RobotSimulator(Direction.North, new Coordinate(0, 0));

        sut.TurnLeft();
        Assert.Equal(0, sut.Coordinate.X);
        Assert.Equal(0, sut.Coordinate.Y);
    }
Beispiel #5
0
        public void TurnLeftTest()
        {
            Robot                  robot            = new Robot();
            TableTop               table            = new TableTop(5, 6);
            IRobotMovingService    movingService    = new ToyRobotMovingService();
            IRobotReportingService reportingService = new ToyRobotReportingService();
            IRobotTurningService   turningService   = new ToyRobotTurningService();

            RobotSimulator simulator = new RobotSimulator(robot, table, movingService, turningService, reportingService);

            Facing defaultFacing = robot.Facing;

            simulator.TurnLeft();
            Assert.AreEqual(defaultFacing, robot.Facing);
            Assert.IsNull(robot.Position);


            simulator.Place(new Position(3, 3), Facing.EAST);

            simulator.TurnLeft();
            Assert.AreEqual(3, robot.Position.X);
            Assert.AreEqual(3, robot.Position.Y);
            Assert.AreEqual(Facing.NORTH, robot.Facing);
        }
        public void Run(Command command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(Command));
            }

            if (command is Command_Left)
            {
                _simulator.TurnLeft();
            }
            else if (command is Command_Right)
            {
                _simulator.TurnRight();
            }
            else if (command is Command_Move)
            {
                _simulator.Move();
            }
            else if (command is Command_Place)
            {
                Command_Place cp = (Command_Place)command;
                _simulator.Place(cp.Position, cp.Facing);
            }
            else if (command is Command_Report)
            {
                string message = _simulator.Report();
                if (message != null)
                {
                    System.Console.WriteLine(message);
                }
            }
            else
            {
                return;
            }
        }
 public void Turn_left_edge_case()
 {
     var robot = new RobotSimulator(Bearing.North, new Coordinate(0, 0));
     robot.TurnLeft();
     Assert.That(robot.Bearing, Is.EqualTo(Bearing.West));
 }