public void RobotCommander_PlacedAndMoved_ReportsCorrectPosition() { var commander = new RobotCommander(new Mock <ILogger>().Object, new RobotAction(new Mock <ILogger>().Object)); commander.Command("PLACE 1,1,NORTH"); commander.Command("MOVE"); Assert.AreEqual("1,2,NORTH", commander.Command("REPORT")); }
public void RobotCommander_PlacedAndMovedOffTable_CannotBeMoved() { var commander = new RobotCommander(new Mock <ILogger>().Object, new RobotAction(new Mock <ILogger>().Object)); commander.Command("PLACE 5,5,NORTH"); commander.Command("MOVE"); Assert.AreEqual("5,5,NORTH", commander.Command("REPORT")); }
public void RobotCommander_PlacedAndTurnedRight_ReportsCorrectPosition() { var commander = new RobotCommander(new Mock <ILogger>().Object, new RobotAction(new Mock <ILogger>().Object)); commander.Command("PLACE 1,1,NORTH"); commander.Command("RIGHT"); Assert.AreEqual("1,1,EAST", commander.Command("REPORT")); }
public void RobotCommander_RecognisedCommand_ReportsValid() { var commander = new RobotCommander(new Mock <ILogger>().Object, new RobotAction(new Mock <ILogger>().Object)); var response = commander.Command("MOVE"); Assert.AreEqual("Robot cannot move until it has been placed on the table.", response); }
public void RobotCommander_PlaceCommandWithInvalidArguments_ReportsInvalid() { var commander = new RobotCommander(new Mock <ILogger>().Object, new RobotAction(new Mock <ILogger>().Object)); var response = commander.Command("PLACE XXX"); Assert.AreEqual(@"Invalid command. The correct command formats are as follows: PLACE X, Y, DIRECTION MOVE RIGHT LEFT REPORT ------------- Please review your input and try again.", response); response = commander.Command("PLACE 1,X,NORTH"); Assert.AreEqual(@"Invalid command. The correct command formats are as follows: PLACE X, Y, DIRECTION MOVE RIGHT LEFT REPORT ------------- Please review your input and try again.", response); response = commander.Command("PLACE X,1,NORTH"); Assert.AreEqual(@"Invalid command. The correct command formats are as follows: PLACE X, Y, DIRECTION MOVE RIGHT LEFT REPORT ------------- Please review your input and try again.", response); response = commander.Command("PLACE 1,1,XXX"); Assert.AreEqual(@"Invalid command. The correct command formats are as follows: PLACE X, Y, DIRECTION MOVE RIGHT LEFT REPORT ------------- Please review your input and try again.", response); }
static void Main(string[] args) { DisplayWelcome(); var kernel = new StandardKernel(); LogHandler.InitialiseLoggingConfig("RobotAction Simulator", true); kernel.Load(Assembly.GetExecutingAssembly()); var robotMover = new RobotCommander(kernel.Get <ILogger>(), kernel.Get <IRobotAction>()); while (true) { var command = PromptForCommand(); if (command.ToUpper() == "EXIT" || command.ToUpper() == "QUIT") { Environment.Exit(0); } Console.WriteLine(robotMover.Command(command)); Console.WriteLine(""); } }