public void Setup() { _tableTop = new TableTop(); _toyRobot = new ToyRobot(); _inputHelper = new InputHelper(); _robotSimulator = new RobotSimulator(_toyRobot, _tableTop, _inputHelper); }
public void Test_ValidationRule_InvalidPlaceCommandThrowsException(int x, int y, Direction f) { IToyRobot toyRobot = CreateSut(); Assert.Throws <Exception>(() => toyRobot.Place(new RobotPosition() { X = x, Y = y, F = f })); }
public void Test_PlaceCommand_SetsCurrentPosition(int x, int y, Direction f) { IToyRobot toyRobot = CreateSut(); toyRobot.Place(new RobotPosition() { X = x, Y = y, F = f }); var currentPosition = toyRobot.Report(); Assert.Equal(x, currentPosition.X); Assert.Equal(y, currentPosition.Y); Assert.Equal(f, currentPosition.F); }
public void Test_RightCommand_RotatesPerpendicularInRightDirection(int x, int y, Direction currentDirection, Direction expectedDirection) { IToyRobot toyRobot = CreateSut(); toyRobot.Place(new RobotPosition() { X = x, Y = y, F = currentDirection }); toyRobot.Right(); var currentPosition = toyRobot.Report(); Assert.Equal(x, currentPosition.X); Assert.Equal(y, currentPosition.Y); Assert.Equal(expectedDirection, currentPosition.F); }
public void Test_MoveCommand_OneUnitInCurrentDirection(int x1, int y1, Direction f1, int x2, int y2, Direction f2) { IToyRobot toyRobot = CreateSut(); toyRobot.Place(new RobotPosition() { X = x1, Y = y1, F = f1 }); toyRobot.Move(); var currentPosition = toyRobot.Report(); Assert.Equal(x2, currentPosition.X); Assert.Equal(y2, currentPosition.Y); Assert.Equal(f2, currentPosition.F); }
public CommandProcessor(int rows, int columns) { if (rows < 0) { throw new Exception($"Table row value should be positive {rows}"); } if (columns < 0) { throw new Exception($"Table column value should be positive {columns}"); } _toyRobot = new ToyRobot(rows, columns); this._moveCommand = new MoveCommand(this._toyRobot); this._leftCommand = new LeftCommand(this._toyRobot); this._rightCommand = new RightCommand(this._toyRobot); this._reportCommand = new ReportCommand(this._toyRobot); }
public Command(IToyRobot toyRobot) { this._toyRobot = toyRobot; }
public MoveCommand(IToyRobot toyRobot) : base(toyRobot) { }
public RightCommand(IToyRobot toyRobot) : base(toyRobot) { }
public Behaviour(IToyRobot toyRobot, IToyBoard squareBoard, IInputParser inputParser) { ToyRobot = toyRobot; SquareBoard = squareBoard; InputParser = inputParser; }
public ReportCommand(IToyRobot toyRobot) : base(toyRobot) { }
public void CleaUp() { this._toyRobot = null; }
public ToyAction(IToyRobot toyRobot, IToyBoard toyBoard, IInputParser inputParser) { ToyRobot = toyRobot; ToyBoard = toyBoard; InputParser = inputParser; }
public CommandHandler(IToyRobot toyRobot, ICommandParser commandParser) { this.toyRobot = toyRobot; this.commandParser = commandParser; }
public RobotSimulator(IToyRobot toyRobot, ITableTop tableTop, IInputHelper inputHelper) { _tableTop = tableTop; _toyRobot = toyRobot; _inputHelper = inputHelper; }
public LeftCommand(IToyRobot toyRobot) : base(toyRobot) { }
public Simulator(IToyRobot toyRobot, ISquareBoard squareBoard, IInputParser inputParser) { this.ToyRobot = toyRobot; this.SquareBoard = squareBoard; this.InputParser = inputParser; }
public PlaceCommand(IToyRobot toyRobot, Point point, string face) : base(toyRobot) { this._point = point; this._face = face; }