# Testability Refactoring — List of Changes

Mode: guided
Source: autodev-testability-analysis + architecture-compliance-baseline F1/F2

## TC-01: Move DownloadedTileInfoV2 to Common

**Files**: `SatelliteProvider.Services/GoogleMapsDownloaderV2.cs` → `SatelliteProvider.Common/DTO/DownloadedTileInfoV2.cs`
**Problem**: `DownloadedTileInfoV2` is defined in Services alongside the concrete downloader. The interface in Common cannot reference it, blocking the interface fix.
**Change**: Move the record to `SatelliteProvider.Common.DTO`. Update namespace references in GoogleMapsDownloaderV2 and TileService.
**Risk**: Low — record has no dependencies on Services-specific types.

## TC-02: Update ISatelliteDownloader interface

**Files**: `SatelliteProvider.Common/Interfaces/ISatelliteDownloader.cs`
**Problem**: Current interface has a single method `GetTiles` with a signature that doesn't match any usage in the codebase (dead code, per baseline F2).
**Change**: Replace with the two methods actually needed by callers:
- `DownloadSingleTileAsync(double latitude, double longitude, int zoomLevel, CancellationToken token = default)`
- `GetTilesWithMetadataAsync(GeoPoint centerGeoPoint, double radiusM, int zoomLevel, IEnumerable<ExistingTileInfo> existingTiles, CancellationToken token = default)`
Introduce `ExistingTileInfo` record in Common to avoid referencing DataAccess.TileEntity from the interface.
**Risk**: Low — the old interface was unused.

## TC-03: GoogleMapsDownloaderV2 implements ISatelliteDownloader

**Files**: `SatelliteProvider.Services/GoogleMapsDownloaderV2.cs`
**Problem**: Concrete class does not implement the interface, so it cannot be swapped in tests (baseline F1).
**Change**: Add `: ISatelliteDownloader` to class declaration. Adjust `GetTilesWithMetadataAsync` parameter from `IEnumerable<TileEntity>` to `IEnumerable<ExistingTileInfo>`.
**Risk**: Medium — method signature change requires updating callers.
**Dependencies**: TC-01, TC-02

## TC-04: TileService depends on ISatelliteDownloader

**Files**: `SatelliteProvider.Services/TileService.cs`
**Problem**: Constructor takes `GoogleMapsDownloaderV2` (concrete). Cannot mock in unit tests.
**Change**: Change constructor parameter and field type from `GoogleMapsDownloaderV2` to `ISatelliteDownloader`. Map `TileEntity` to `ExistingTileInfo` before calling the interface.
**Risk**: Low — no public API change.
**Dependencies**: TC-02, TC-03

## TC-05: Update DI registration and API endpoint

**Files**: `SatelliteProvider.Api/Program.cs`
**Problem**: `GoogleMapsDownloaderV2` registered as concrete singleton. `ServeTile` endpoint injects concrete class directly.
**Change**: Register as `ISatelliteDownloader` → `GoogleMapsDownloaderV2`. Change `ServeTile` to inject `ISatelliteDownloader`.
**Risk**: Low — behavior unchanged, just the injection type.
**Dependencies**: TC-03

## Deferred to Step 8 Refactor

- **Medium finding: ServeTile bypasses service layer** — The endpoint directly uses `ITileRepository` and the downloader instead of `ITileService`. Moving this logic into the service layer would be cleaner but changes module boundaries (not allowed in testability step).
- **Medium finding: No physical boundaries in Services project** — All services share one project. Splitting into separate projects is a structural change beyond testability scope.
