mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 14:31:13 +00:00
6f23120c49
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>
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
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");
|
|
}
|
|
}
|