using FluentAssertions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using SatelliteProvider.Common.Configs; using SatelliteProvider.Common.DTO; using SatelliteProvider.Services; using Xunit; namespace SatelliteProvider.Tests; public class GoogleMapsDownloaderTests { [Fact] public async Task IntegrationTest_DownloadRealTiles_ShouldDownloadBytes() { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var mapConfig = new MapConfig(); configuration.GetSection("MapConfig").Bind(mapConfig); var services = new ServiceCollection(); services.AddHttpClient(); services.AddLogging(builder => builder.AddConsole()); var serviceProvider = services.BuildServiceProvider(); var logger = serviceProvider.GetRequiredService>(); var options = Options.Create(mapConfig); var httpClientFactory = serviceProvider.GetRequiredService(); var downloader = new GoogleMapsDownloader(logger, options, httpClientFactory); var centerPoint = new GeoPoint(37.7749, -122.4194); var radius = 200.0; var zoomLevel = 15; await downloader.GetTiles(centerPoint, radius, zoomLevel); var mapsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "maps"); Directory.Exists(mapsDirectory).Should().BeTrue(); var files = Directory.GetFiles(mapsDirectory, "*.jpg"); files.Should().NotBeEmpty(); var totalBytes = files.Sum(file => new FileInfo(file).Length); totalBytes.Should().BeGreaterThan(0); foreach (var file in files) { File.Delete(file); } } }