mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 09:51:14 +00:00
9a53bff92e
Batch 24 of 03-code-quality-refactoring run; closes the run. AZ-375 (C22): GoogleMapsDownloaderV2.DownloadTilesGridAsync now builds a HashSet<(int X, int Y, int Z)> once from existingTiles and tests Contains((x, y, zoomLevel)) per cell. Removes the per-cell FirstOrDefault tolerance scan and the unused _processingConfig .LatLonTolerance reference at this site. AZ-377 (C24): promote Earth + tile-pixel constants to a single home. GeoUtils now exposes EarthRadiusMeters, EarthEquatorial CircumferenceMeters, MetersPerDegreeLatitude as public const. MapConfig adds DefaultTileSizePixels (const) wired as the TileSizePixels property default. TileRepository and Google MapsDownloaderV2 read those constants instead of duplicating the literals 6378137, 40075016.686, 111000.0, and 256. Tests: +6 new (DownloaderRefactorTests, extended GeoUtils RefactorTests). 200/200 unit tests pass. Cumulative K=3 review (batches 22-24): PASS_WITH_WARNINGS, 4 Low findings only — see _docs/03_implementation/reviews/cumulative_review_22-24.md. Tooling fix: scripts/run-tests.sh --unit-only path now restores before testing (was failing on SixLabors resolution in clean container). Stripped stray BOM from MapConfig.cs to satisfy the .editorconfig charset gate. Updates _dependencies_table.md to reflect all 27 03-code-quality- refactoring tasks done; updates _autodev_state.md to refactor phase 5 (test-sync). Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using System.Reflection;
|
|
using FluentAssertions;
|
|
using SatelliteProvider.Common.Configs;
|
|
using SatelliteProvider.Common.DTO;
|
|
using SatelliteProvider.Common.Utils;
|
|
|
|
namespace SatelliteProvider.Tests;
|
|
|
|
public class GeoUtilsRefactorTests
|
|
{
|
|
[Fact]
|
|
public void GeoUtils_DoesNotExposeCalculatePolygonDiagonalDistance_AZ380_AC1()
|
|
{
|
|
// Assert
|
|
typeof(GeoUtils).GetMethod("CalculatePolygonDiagonalDistance").Should().BeNull(
|
|
"AZ-380 deletes the dead alias method that simply forwarded to CalculateDistance");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("EarthRadiusMeters", 6378137d)]
|
|
[InlineData("EarthEquatorialCircumferenceMeters", 40075016.686d)]
|
|
[InlineData("MetersPerDegreeLatitude", 111000d)]
|
|
public void GeoUtils_ExposesEarthConstantsAsPublicConst_AZ377_AC1(string fieldName, double expected)
|
|
{
|
|
// Arrange
|
|
var field = typeof(GeoUtils).GetField(fieldName, BindingFlags.Public | BindingFlags.Static);
|
|
|
|
// Assert
|
|
field.Should().NotBeNull($"AZ-377 promotes {fieldName} to a public const on GeoUtils");
|
|
field!.IsLiteral.Should().BeTrue($"{fieldName} must be a const so call sites can reference it without runtime cost");
|
|
field.FieldType.Should().Be(typeof(double));
|
|
field.GetRawConstantValue().Should().Be(expected, "AZ-377 forbids numerical drift from the previous literal");
|
|
}
|
|
|
|
[Fact]
|
|
public void MapConfig_ExposesDefaultTileSizePixelsConst_AZ377_AC1()
|
|
{
|
|
// Arrange
|
|
var field = typeof(MapConfig).GetField("DefaultTileSizePixels", BindingFlags.Public | BindingFlags.Static);
|
|
|
|
// Assert
|
|
field.Should().NotBeNull("AZ-377 introduces a const so DataAccess can reference the canonical pixel size without IOptions");
|
|
field!.IsLiteral.Should().BeTrue();
|
|
field.GetRawConstantValue().Should().Be(256);
|
|
new MapConfig().TileSizePixels.Should().Be(MapConfig.DefaultTileSizePixels,
|
|
"the instance default must remain wired to the const so config-bound consumers stay in sync");
|
|
}
|
|
|
|
[Fact]
|
|
public void GeoUtils_HaversineProducesIdenticalResultAfterConstantRename_AZ377_AC2()
|
|
{
|
|
// Arrange
|
|
var a = new GeoPoint(50.4501, 30.5234);
|
|
var b = new GeoPoint(50.4501, 30.6234);
|
|
|
|
// Act
|
|
var d = GeoUtils.CalculateDistance(a, b);
|
|
|
|
// Assert
|
|
d.Should().BeApproximately(7090d, 5d,
|
|
"renaming EARTH_RADIUS to EarthRadiusMeters must not change Haversine output");
|
|
}
|
|
}
|