Files
satellite-provider/SatelliteProvider.IntegrationTests/TileTests.cs
T
Oleksandr Bezdieniezhnykh 534ab41b8e
ci/woodpecker/push/01-test Pipeline was successful
ci/woodpecker/push/02-build-push Pipeline was successful
[AZ-372] Apply dotnet format whitespace cleanup; archive batch 22
Pure whitespace-only cleanup uncovered by the new format gate from the
previous commit. Verified via `git diff -w --stat`: only 4 files differ
when whitespace is ignored, and those differ only by the BOM byte.

Cleanup kinds applied across 22 source files:
- BOM removal (MapConfig.cs, SatTile.cs, GeoUtils.cs,
  IntegrationTests/Program.cs)
- CRLF -> LF (IntegrationTests/Program.cs)
- Trailing whitespace on blank lines (Common, Api, DataAccess,
  IntegrationTests, Services.RegionProcessing,
  Services.TileDownloader)
- Final newline added (RoutePoint.cs, GeoPoint.cs, others)

After this commit `dotnet format whitespace SatelliteProvider.sln
--verify-no-changes` exits 0; AC-1 is enforceable from `scripts/
run-tests.sh` going forward.

Also lands the batch 22 report, code-review report
(PASS_WITH_WARNINGS, 2 Low findings — both deferred per spec),
dependency-table status update (AZ-372 -> Done (In Testing)), task
archive (todo/ -> done/), and autodev state update.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 04:43:08 +03:00

99 lines
3.6 KiB
C#

using System.Net.Http.Json;
using System.Text.Json;
namespace SatelliteProvider.IntegrationTests;
public static class TileTests
{
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
public static async Task RunGetTileByLatLonTest(HttpClient httpClient)
{
Console.WriteLine("Test: Get Tile by Lat/Lon at Coordinates 47.461747, 37.647063");
Console.WriteLine("------------------------------------------------------------------");
const double latitude = 47.461747;
const double longitude = 37.647063;
const int zoomLevel = 18;
Console.WriteLine($"Getting tile at coordinates ({latitude}, {longitude}) with zoom level {zoomLevel}");
var response = await httpClient.GetAsync($"/api/satellite/tiles/latlon?Latitude={latitude}&Longitude={longitude}&ZoomLevel={zoomLevel}");
if (!response.IsSuccessStatusCode)
{
var errorContent = await response.Content.ReadAsStringAsync();
throw new Exception($"API returned error status {response.StatusCode}: {errorContent}");
}
var tile = await response.Content.ReadFromJsonAsync<DownloadTileResponse>(JsonOptions);
if (tile == null)
{
throw new Exception("No tile data returned from API");
}
Console.WriteLine();
Console.WriteLine("Tile Details:");
Console.WriteLine($" ID: {tile.Id}");
Console.WriteLine($" Zoom Level: {tile.ZoomLevel}");
Console.WriteLine($" Latitude: {tile.Latitude}");
Console.WriteLine($" Longitude: {tile.Longitude}");
Console.WriteLine($" Tile Size (meters): {tile.TileSizeMeters:F2}");
Console.WriteLine($" Tile Size (pixels): {tile.TileSizePixels}");
Console.WriteLine($" Image Type: {tile.ImageType}");
Console.WriteLine($" File Path: {tile.FilePath}");
Console.WriteLine($" Created At: {tile.CreatedAt:yyyy-MM-dd HH:mm:ss}");
if (tile.ZoomLevel != zoomLevel)
{
throw new Exception($"Expected zoom level {zoomLevel}, got {tile.ZoomLevel}");
}
if (string.IsNullOrEmpty(tile.FilePath))
{
throw new Exception("File path is empty");
}
if (tile.TileSizePixels != 256)
{
throw new Exception($"Expected tile size 256 pixels, got {tile.TileSizePixels}");
}
if (tile.ImageType != "jpg")
{
throw new Exception($"Expected image type 'jpg', got '{tile.ImageType}'");
}
Console.WriteLine();
Console.WriteLine("✓ Tile retrieved successfully");
Console.WriteLine("✓ Tile metadata validated");
Console.WriteLine();
Console.WriteLine("Testing tile reuse (getting same tile again)...");
var response2 = await httpClient.GetAsync($"/api/satellite/tiles/latlon?Latitude={latitude}&Longitude={longitude}&ZoomLevel={zoomLevel}");
if (!response2.IsSuccessStatusCode)
{
var errorContent = await response2.Content.ReadAsStringAsync();
throw new Exception($"Second request failed with status {response2.StatusCode}: {errorContent}");
}
var tile2 = await response2.Content.ReadFromJsonAsync<DownloadTileResponse>(JsonOptions);
if (tile2 == null)
{
throw new Exception("No tile data returned from second request");
}
Console.WriteLine($"✓ Second request returned tile ID: {tile2.Id}");
Console.WriteLine("✓ Tile reuse functionality working");
Console.WriteLine();
Console.WriteLine("Get Tile by Lat/Lon Test: PASSED");
}
}