public void RoverCanTrackMovingOutOfBoundaryError() { var rover = new Rover.Rover(_fixture.map, new RoverState(1, 1, Directions.South)); rover.MoveForward(); Assert.Null(rover.GetLastError()); rover.MoveForward(); Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError()); //rover should stop moving when it's next step is out of boundary rover.MoveForward(); Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError()); }
public void RoverCanTrackCreationOutOfBoundarysError() { var x = _fixture.map.maxX + 1; var y = _fixture.map.maxY + 1; var rover = new Rover.Rover(_fixture.map, new RoverState(x, y, Directions.South)); Assert.Equal($"({x},{y}) is out of map boundary.", rover.GetLastError()); }
public int?CreateRover(int x, int y, Directions direction) { if (_map == null) { _errors.Push("Map is null."); return(null); } var roverId = NextRoverId(); var rover = new Rover(_map, new RoverState(x, y, direction)); if (rover.GetLastError() != null) { _errors.Push($"Failed to create Rover: {rover.GetLastError()}"); return(null); } _rovers.Add(roverId, rover); return(roverId); }