示例#1
0
 public void RobotDriver_PlacedAndMoved_ReportsCorrectPosition()
 {
     var driver = new RobotDriver(new Robot());
     driver.Command("PLACE 1,1,NORTH");
     driver.Command("MOVE");
     Assert.AreEqual("1,2,NORTH", driver.Command("REPORT"));
 }
示例#2
0
 public void RobotDriver_PlacedAndTurnedRight_ReportsCorrectPosition()
 {
     var driver = new RobotDriver(new Robot());
     driver.Command("PLACE 1,1,NORTH");
     driver.Command("RIGHT");
     Assert.AreEqual("1,1,EAST", driver.Command("REPORT"));
 }
示例#3
0
 public void RobotDriver_PlacedAndMovedOffTable_CannotBeMoved()
 {
     var driver = new RobotDriver(new Robot());
     driver.Command("PLACE 5,5,NORTH");
     driver.Command("MOVE");
     Assert.AreEqual("5,5,NORTH", driver.Command("REPORT"));
 }
示例#4
0
 public void RobotDriver_PlaceCommandWithInvalidArguments_ReportsInvalid()
 {
     var driver = new RobotDriver(new Robot());
     var response = driver.Command("PLACE XXX");
     Assert.AreEqual("Invalid command.", response);
     response = driver.Command("PLACE 1,X,NORTH");
     Assert.AreEqual("Invalid command.", response);
     response = driver.Command("PLACE X,1,NORTH");
     Assert.AreEqual("Invalid command.", response);
     response = driver.Command("PLACE 1,1,XXX");
     Assert.AreEqual("Invalid command.", response);
 }
示例#5
0
        static void Main(string[] args)
        {
            DisplayWelcome();

            var driver = new RobotDriver(new Robot());

            while (true)
            {
                string command = PromptForCommand();
                if (command.ToUpper() == "EXIT" || command.ToUpper() == "QUIT")
                {
                    Environment.Exit(0);
                }
                Console.WriteLine(driver.Command(command));
            }
        }
示例#6
0
 public void RobotDriver_PlaceCommandWithNoArguments_ReportsInvalid()
 {
     var driver = new RobotDriver(new Robot());
     var response = driver.Command("PLACE");
     Assert.AreEqual("Invalid command.", response);
 }
示例#7
0
 public void RobotDriver_InitialisedRobotDriver_ControlsRobot()
 {
     var driver = new RobotDriver(new Robot());
     Assert.IsNotNull(driver.Robot);
 }
示例#8
0
 public void RobotDriver_EmptyCommand_ReportsInvalid()
 {
     var driver = new RobotDriver(new Robot());
     var response = driver.Command("");
     Assert.AreEqual("Invalid command.", response);
 }
示例#9
0
 public void RobotDriver_UnrecognisedCommand_ReportsInvalid()
 {
     var driver = new RobotDriver(new Robot());
     var response = driver.Command("XXXX");
     Assert.AreEqual("Invalid command.", response);
 }
示例#10
0
 public void RobotDriver_RecognisedCommand_ReportsValid()
 {
     var driver = new RobotDriver(new Robot());
     var response = driver.Command("MOVE");
     Assert.AreEqual("Robot cannot move until it has been placed on the table.", response);
 }