public void Init() { _commandRecorder = new CommandRecorder(); _robotCommandHandler = new RobotCommandHandler(_commandRecorder); _replayRobotCommand = new ReplayRobotCommand(_robotCommandHandler); _beepRobotCommand = new BeepRobotCommand(_commandRecorder); _moveRobotCommand = new MoveRobotCommand(_commandRecorder); _turnRobotCommand = new TurnRobotCommand(_commandRecorder); _robot = MockRepository.GenerateStub <IRobot>(); }
static void Main(string[] args) { ICommandRecorder commandRecorder = new CommandRecorder(); RobotCommandHandler robotCammandHandler = new RobotCommandHandler(commandRecorder); RobotCommandType drawingCommand = RobotCommandType.None; Console.WriteLine("Welcome to the Mock Robot Interface:"); Console.WriteLine("'Move' command will move Robot A. Syntax: M <Distance in Decimal number> Example: M 10.3"); Console.WriteLine("'Turn' command will Turn Robot A. Syntax: T <Angle in Decimal number> Eg: T 45.8"); Console.WriteLine("'Beep' command will Beep Robot A. Syntax: B"); Console.WriteLine("'Replay' command will replay all the past commands sent to Robot A on Robot B. Syntax: R"); Console.WriteLine("'Quit' command syntax not matched. Syntax: Q"); do { IRobot robotA = new MockRobotA(); IRobot robotB = new MockRobotB(); IRobot robot; try { Console.Write("Enter Command: "); var commandStr = Console.ReadLine(); if (commandStr != null && commandStr.Trim().ToUpper() == "R") { robot = robotB; } else { robot = robotA; } drawingCommand = RobotCommandType.None; try { drawingCommand = robotCammandHandler.Run(robot, commandStr); } catch (Exception e) { Console.WriteLine(e.Message); } } catch (Exception e) { Console.WriteLine(e.Message); } } while (drawingCommand != RobotCommandType.Quit); Console.WriteLine("Press a key to Quit"); Console.ReadKey(); }
public void GetCommandAsListNegativeTest(string str) { var ex = Assert.Throws(typeof(ArgumentException), () => RobotCommandHandler.GetCommandAsList(str)); Assert.That(ex.Message, Is.EqualTo("Invalid command. Command cannot be blank.")); }
public void GetCommandAsListPositiveTest(string str, List <string> result) { Assert.AreEqual(RobotCommandHandler.GetCommandAsList(str), result); }
public void Init() { _commandRecorder = new CommandRecorder(); _robotCommandHandler = new RobotCommandHandler(_commandRecorder); _robot = MockRepository.GenerateStub <IRobot>(); }