public async Task IsValidXMove_WhenMoveIsValid_ShouldReturnTrue(int plateauX, int xMove) { _plateauMock.SetupGet(p => p.X).Returns(plateauX); var isValid = await _moveValidator.IsValidXMove(xMove); Assert.True(isValid); }
public async Task <MoveResult> Handle(MoveForwardCommand request, CancellationToken cancellationToken) { int xAfterMoving = request.CurrentPosition.X; int yAfterMoving = request.CurrentPosition.Y; switch (request.Direction) { case Direction.North: yAfterMoving++; break; case Direction.East: xAfterMoving++; break; case Direction.South: yAfterMoving--; break; case Direction.West: xAfterMoving--; break; } ; if (!await _moveValidator.IsValidXMove(xAfterMoving) || !await _moveValidator.IsValidYMove(yAfterMoving)) { return(CreateMoveResult(request.CurrentPosition)); } return(CreateMoveResult(new Point { X = xAfterMoving, Y = yAfterMoving })); }