コード例 #1
0
 public void shouldRaiseAnErrorIfRobotNotProperlyPlacedWhenTryingToGetThePosition()
 {
     var robot = new	Robot ();
     var result = robot.GetRobotPosition ();
     Assert.AreEqual ("", result);
     Assert.AreEqual ("Robot cannot Get Robot Position until it has been properly placed", robot.error);
 }
コード例 #2
0
 public void shouldRaiseAnErrorIfRobotNotProperlyPlacedWhenTurning()
 {
     var robot = new	Robot ();
     var result = robot.TurnRight ();
     Assert.IsFalse (result);
     Assert.AreEqual ("Robot cannot turn until it has been properly placed", robot.error);
 }
コード例 #3
0
 public void robotShouldReportCorrectPositionWhenTurnedRight()
 {
     var robot = new Robot ();
     var result = robot.PlaceRobot (1, 1, DirectionFacing.South);
     robot.TurnRight ();
     Assert.IsTrue (result);
     Assert.AreEqual ("1, 1, West", robot.GetRobotPosition ());
 }
コード例 #4
0
 public void robotShouldMoveAndReportPositionCorrectly()
 {
     var robot = new Robot ();
     robot.PlaceRobot (1, 1, DirectionFacing.West);
     var result = robot.Move ();
     Assert.IsTrue (result);
     Assert.AreEqual ("0, 1, West", robot.GetRobotPosition ());
 }
コード例 #5
0
 public void robotShouldMoveAndTurnAndReportItsPosition()
 {
     var robot = new Robot ();
     robot.PlaceRobot (1, 1, DirectionFacing.East);
     robot.Move ();
     robot.TurnLeft ();
     robot.Move ();
     robot.Move ();
     Assert.AreEqual ("2, 3, North", robot.GetRobotPosition ());
 }
コード例 #6
0
        public void shouldRaiseAnErrorWhenRobotIsPlacedOutsideTheGrid()
        {
            var robot = new Robot ();
            var result = robot.PlaceRobot (-2, 0, DirectionFacing.North);
            Assert.IsFalse (result);
            Assert.AreEqual ("Invalid placement, robot cannot place there", robot.error);

            result = robot.PlaceRobot (6, 0, DirectionFacing.South);
            Assert.IsFalse (result);
            Assert.AreEqual ("Invalid placement, robot cannot place there", robot.error);
        }
コード例 #7
0
 public void shouldRaiseAnErrorWhenTryToMoveRobotOutOfTheGrid()
 {
     var robot = new Robot ();
     robot.PlaceRobot (5, 5, DirectionFacing.North);
     var result = robot.Move ();
     Assert.IsFalse (result);
     Assert.AreEqual ("Invalid placement, robot cannot move there", robot.error);
     Assert.AreEqual ("5, 5, North", robot.GetRobotPosition ());
 }
コード例 #8
0
 public void shouldReportRobotPositionWhenCorrectlyPlacedOnTheGrid()
 {
     var robot = new Robot ();
     var result = robot.PlaceRobot (2, 1, DirectionFacing.West);
     var position = robot.GetRobotPosition ();
     Assert.IsTrue (result);
     Assert.AreEqual ("", robot.error);
     Assert.AreEqual ("2, 1, West", position);
 }
コード例 #9
0
 public RobotSimulator(Robot robot)
 {
     this.Robot = robot;
 }