mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 08:31:14 +00:00
12b582deac
Move cache+DB+download logic for /tiles/{z}/{x}/{y} and
/api/satellite/tiles/latlon out of Program.cs into TileService.
Endpoints now inject only ITileService + ILogger. Service owns
IMemoryCache (1h absolute / 30min sliding preserved). Added
TileBytes DTO; ITileService gains GetOrDownloadTileAsync and
DownloadAndStoreSingleTileAsync. 5 new unit tests cover cache
hit, repo hit, downloader fallback, and AZ-311 happy + error.
Build clean (0/0), unit suite 40/40. Resolves architecture
baseline F3 in code (docs handled by AZ-315).
Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using FluentAssertions;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Moq;
|
|
using SatelliteProvider.Common.DTO;
|
|
using SatelliteProvider.Common.Interfaces;
|
|
using SatelliteProvider.DataAccess.Models;
|
|
using SatelliteProvider.DataAccess.Repositories;
|
|
using SatelliteProvider.Services;
|
|
using SatelliteProvider.Tests.Fixtures;
|
|
|
|
namespace SatelliteProvider.Tests;
|
|
|
|
public class InfrastructureTests
|
|
{
|
|
[Fact]
|
|
public void AllMockableInterfaces_CanBeMocked()
|
|
{
|
|
// Arrange + Act
|
|
var downloader = new Mock<ISatelliteDownloader>();
|
|
var tileRepo = new Mock<ITileRepository>();
|
|
var regionRepo = new Mock<IRegionRepository>();
|
|
var routeRepo = new Mock<IRouteRepository>();
|
|
var queue = new Mock<IRegionRequestQueue>();
|
|
var tileService = new Mock<ITileService>();
|
|
var regionService = new Mock<IRegionService>();
|
|
var routeService = new Mock<IRouteService>();
|
|
|
|
// Assert
|
|
downloader.Object.Should().NotBeNull();
|
|
tileRepo.Object.Should().NotBeNull();
|
|
regionRepo.Object.Should().NotBeNull();
|
|
routeRepo.Object.Should().NotBeNull();
|
|
queue.Object.Should().NotBeNull();
|
|
tileService.Object.Should().NotBeNull();
|
|
regionService.Object.Should().NotBeNull();
|
|
routeService.Object.Should().NotBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void TestCoordinates_TileCenter_MatchesPrimaryTilePoint()
|
|
{
|
|
// Assert
|
|
TestCoordinates.TileCenter.Lat.Should().Be(47.461747);
|
|
TestCoordinates.TileCenter.Lon.Should().Be(37.647063);
|
|
TestCoordinates.DefaultZoom.Should().Be(18);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestCoordinates_RoutePoints_HaveExpectedCounts()
|
|
{
|
|
// Assert
|
|
TestCoordinates.Route.Route01Points.Should().HaveCount(2);
|
|
TestCoordinates.Route.Route04Points.Should().HaveCount(10);
|
|
TestCoordinates.Route.Route06Points.Should().HaveCount(20);
|
|
}
|
|
|
|
[Fact]
|
|
public void TileService_ConstructsWithMockedDependencies()
|
|
{
|
|
// Arrange
|
|
var downloader = new Mock<ISatelliteDownloader>().Object;
|
|
var tileRepo = new Mock<ITileRepository>().Object;
|
|
var cache = new MemoryCache(new MemoryCacheOptions());
|
|
var logger = NullLogger<TileService>.Instance;
|
|
|
|
// Act
|
|
var service = new TileService(downloader, tileRepo, cache, logger);
|
|
|
|
// Assert
|
|
service.Should().NotBeNull();
|
|
}
|
|
}
|