[AZ-371] Refactor C18: magic numbers to ProcessingConfig/MapConfig

Promotes 8 operational levers into config keys with defaults that match
the prior source literals byte-for-byte:
  ProcessingConfig: RegionProcessingTimeoutSeconds (300),
  RouteProcessingPollIntervalSeconds (5),
  MaxRoutePointSpacingMeters (200), LatLonTolerance (0.0001).
  MapConfig: TileSizePixels (256), AllowedZoomLevels ([15..19]),
  RetryBaseDelaySeconds (1), RetryMaxDelaySeconds (30).

Sites updated: RegionService, RouteProcessingService,
RoutePointGraphBuilder, RouteValidator, RouteService 4-arg ctor,
RouteImageRenderer, GoogleMapsDownloaderV2, TileService. Closes LF-2 by
forwarding HttpContext.RequestAborted from GetTileByLatLon into the
downloader. appsettings.json gains the 8 new keys at default values.

Tests: 141 / 141 unit + 5 / 5 smoke green. New ConfigDefaultsTests pins
defaults to original literals; new TileService unit test asserts CT
identity from caller to downloader (AZ-371 AC-3).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 03:30:07 +03:00
parent ee42b1716b
commit 1dcd089d39
21 changed files with 404 additions and 68 deletions
@@ -24,6 +24,7 @@ public class TileServiceTests
downloader.Object,
tileRepo.Object,
cache ?? new MemoryCache(new MemoryCacheOptions()),
Options.Create(new MapConfig { Service = "GoogleMaps", ApiKey = "" }),
NullLogger<TileService>.Instance);
}
@@ -372,6 +373,28 @@ public class TileServiceTests
tileRepo.Verify(r => r.InsertAsync(It.IsAny<TileEntity>()), Times.Once);
}
[Fact]
public async Task DownloadAndStoreSingleTileAsync_ForwardsCancellationTokenToDownloader_AZ371_AC3()
{
// Arrange
const int zoom = 18;
var downloader = new Mock<ISatelliteDownloader>();
var tileRepo = new Mock<ITileRepository>();
CancellationToken capturedToken = default;
downloader
.Setup(d => d.DownloadSingleTileAsync(It.IsAny<double>(), It.IsAny<double>(), zoom, It.IsAny<CancellationToken>()))
.Callback<double, double, int, CancellationToken>((_, _, _, ct) => capturedToken = ct)
.ReturnsAsync(new DownloadedTileInfoV2(1, 2, zoom, 0, 0, "p.jpg", 100.0));
var service = BuildService(downloader, tileRepo);
using var cts = new CancellationTokenSource();
// Act
await service.DownloadAndStoreSingleTileAsync(0, 0, zoom, cts.Token);
// Assert
capturedToken.Should().Be(cts.Token, "AZ-371 AC-3: caller-supplied CT must reach the downloader");
}
[Fact]
public async Task DownloadAndStoreSingleTileAsync_DownloaderThrows_DoesNotInsert_AZ311_AC2b()
{