mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 19:51:15 +00:00
[AZ-364] [AZ-360] Refactor C11+C08: decompose RouteProcessingService
Extracts RouteRegionMatcher, RouteCsvWriter, RouteSummaryWriter, RouteImageRenderer, TilesZipBuilder, RegionFileCleaner from the ~750-LOC RouteProcessingService god-class. Moves TileInfo to its own file as a sealed record. Replaces IServiceProvider scope- locator with a direct IRegionService injection (folds AZ-360 / C08). Updates DI registration and tests. Tests: 133 / 133 unit + 5 / 5 smoke green; integration suite exit 0. Pixel-equivalent stitched route image and byte-equivalent CSV / summary / ZIP outputs verified through the smoke run. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SatelliteProvider.Common.Configs;
|
||||
using SatelliteProvider.Services.RouteManagement;
|
||||
|
||||
namespace SatelliteProvider.Tests;
|
||||
|
||||
// AZ-364 / C11: route-side CSV writer wraps the shared TileCsvWriter and
|
||||
// owns the route_<id>_ready.csv path. Only the wrapping behavior (path,
|
||||
// row mapping, returned path) is tested here; CSV byte format is the
|
||||
// shared TileCsvWriter's concern (covered separately).
|
||||
public class RouteCsvWriterTests : IDisposable
|
||||
{
|
||||
private readonly string _tempDir;
|
||||
|
||||
public RouteCsvWriterTests()
|
||||
{
|
||||
_tempDir = Path.Combine(Path.GetTempPath(), "az364_routecsv_" + Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(_tempDir);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Directory.Exists(_tempDir))
|
||||
{
|
||||
Directory.Delete(_tempDir, recursive: true);
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WriteAsync_ProducesExpectedFileAndReturnsItsPath_AZ364_AC1()
|
||||
{
|
||||
// Arrange
|
||||
var routeId = Guid.NewGuid();
|
||||
var storageOptions = Options.Create(new StorageConfig { ReadyDirectory = _tempDir });
|
||||
var sut = new RouteCsvWriter(storageOptions, NullLogger<RouteCsvWriter>.Instance);
|
||||
var tiles = new List<TileInfo>
|
||||
{
|
||||
new(40.0, -73.0, "/tiles/a.jpg"),
|
||||
new(41.0, -74.0, "/tiles/b.jpg"),
|
||||
};
|
||||
|
||||
// Act
|
||||
var path = await sut.WriteAsync(routeId, tiles);
|
||||
|
||||
// Assert
|
||||
path.Should().Be(Path.Combine(_tempDir, $"route_{routeId}_ready.csv"));
|
||||
File.Exists(path).Should().BeTrue();
|
||||
|
||||
var lines = await File.ReadAllLinesAsync(path);
|
||||
lines.Should().HaveCount(3);
|
||||
lines[0].Should().Be("latitude,longitude,file_path");
|
||||
lines.Should().Contain("41.000000,-74.000000,/tiles/b.jpg");
|
||||
lines.Should().Contain("40.000000,-73.000000,/tiles/a.jpg");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user