public ActionResult <Position> Get(int x, int y, string direction, string commandSequence) { var position = new PositionStruct { Coordinate = new Coordinate(x, y), Direction = direction.ToDirection() }; var finalPosition = Hover.BatchMove(position, commandSequence); return(Ok(finalPosition.ToPositionModel())); }
public void BatchMove_ShouldMoveALotAndReturnToSamePosition(int initialX, int initialY, Direction initialDirection, string commandSequence) { // Arrange var initialPosition = new Position { Coordinate = new Coordinate(initialX, initialY), Direction = initialDirection }; // Act var testedPosition = Hover.BatchMove(initialPosition, commandSequence); // Assert testedPosition.ShouldBe(initialPosition); }
public void BatchMove_ShouldHitFirstObstacle(int initialX, int initialY, Direction initialDirection, string commandSequence, string obstacleSequence) { // Arrange var initialPosition = new Position { Coordinate = new Coordinate(initialX, initialY), Direction = initialDirection }; // Act void BatchMove() { Hover.BatchMove(initialPosition, commandSequence, obstacleSequence); } //Assert Should.Throw <CollisionException>(BatchMove); }
public void BatchMove_ShouldMatchCoordinateAndDirection(int initialX, int initialY, Direction initialDirection, string commandSequence, int finalX, int finalY, Direction finalDirection) { // Arrange var initialPosition = new Position { Coordinate = new Coordinate(initialX, initialY), Direction = initialDirection }; var finalPosition = new Position { Coordinate = new Coordinate(finalX, finalY), Direction = finalDirection }; // Act var testedPosition = Hover.BatchMove(initialPosition, commandSequence); // Assert testedPosition.ShouldBe(finalPosition); }
static void Main(string[] args) { var position = new Position { Coordinate = new Coordinate(0, 0), Direction = Direction.East }; try { position = Hover.BatchMove(position, "FFFFF", "[[3,1], [5, 0], [3, 5]]"); } catch (CollisionException e) { System.Console.WriteLine(e.Message); } System.Console.ReadKey(); }
public ActionResult <Position> Get(int x, int y, string direction, string commandSequence, string obstacleSequence) { var position = new PositionStruct { Coordinate = new Coordinate(x, y), Direction = direction.ToDirection() }; try { var finalPosition = Hover.BatchMove(position, commandSequence, obstacleSequence); return(Ok(finalPosition.ToPositionModel())); } catch (CollisionException e) { return(Ok(e.Message)); } catch (InvalidObstacleListException e) { return(BadRequest(e.Message)); } }