mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:16:39 +00:00
make structure
add tests
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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<ILogger<GoogleMapsDownloader>>();
|
||||
var options = Options.Create(mapConfig);
|
||||
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="8.8.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.10" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SatelliteProvider.Services\SatelliteProvider.Services.csproj" />
|
||||
<ProjectReference Include="..\SatelliteProvider.Common\SatelliteProvider.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"MapConfig": {
|
||||
"ApiKey": "AIzaSyAXRBDBOskC5QOHG6VJWzmVJwYKcu6WH8k"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user