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);
        }
Example #6
0
        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);
        }
Example #7
0
 public Command(IToyRobot toyRobot)
 {
     this._toyRobot = toyRobot;
 }
Example #8
0
 public MoveCommand(IToyRobot toyRobot) : base(toyRobot)
 {
 }
Example #9
0
 public RightCommand(IToyRobot toyRobot) : base(toyRobot)
 {
 }
Example #10
0
 public Behaviour(IToyRobot toyRobot, IToyBoard squareBoard, IInputParser inputParser)
 {
     ToyRobot    = toyRobot;
     SquareBoard = squareBoard;
     InputParser = inputParser;
 }
Example #11
0
 public ReportCommand(IToyRobot toyRobot) : base(toyRobot)
 {
 }
Example #12
0
 public void CleaUp()
 {
     this._toyRobot = null;
 }
Example #13
0
 public ToyAction(IToyRobot toyRobot, IToyBoard toyBoard, IInputParser inputParser)
 {
     ToyRobot    = toyRobot;
     ToyBoard    = toyBoard;
     InputParser = inputParser;
 }
Example #14
0
 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;
 }
Example #16
0
 public LeftCommand(IToyRobot toyRobot) : base(toyRobot)
 {
 }
 public Simulator(IToyRobot toyRobot, ISquareBoard squareBoard, IInputParser inputParser)
 {
     this.ToyRobot = toyRobot;
     this.SquareBoard = squareBoard;
     this.InputParser = inputParser;
 }
Example #18
0
 public PlaceCommand(IToyRobot toyRobot, Point point, string face) : base(toyRobot)
 {
     this._point = point;
     this._face  = face;
 }