diff --git a/ImageMapper.slnx b/ImageMapper.slnx index ea4f6eb..f041c06 100644 --- a/ImageMapper.slnx +++ b/ImageMapper.slnx @@ -8,5 +8,6 @@ + diff --git a/src/ImageMapper.Tests/ImageMapper.Tests.csproj b/src/ImageMapper.Tests/ImageMapper.Tests.csproj new file mode 100644 index 0000000..67a1ead --- /dev/null +++ b/src/ImageMapper.Tests/ImageMapper.Tests.csproj @@ -0,0 +1,35 @@ + + + + net9.0 + enable + enable + false + true + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + diff --git a/src/ImageMapper.Tests/IntegrationTest.cs b/src/ImageMapper.Tests/IntegrationTest.cs new file mode 100644 index 0000000..320fbb8 --- /dev/null +++ b/src/ImageMapper.Tests/IntegrationTest.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.Logging; + +namespace ImageMapper.Tests +{ + public class IntegrationTest + { + private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30); + + [Test] + public async Task GetWebResourceRootReturnsOkStatusCode() + { + // Arrange + using var cts = new CancellationTokenSource(DefaultTimeout); + var cancellationToken = cts.Token; + var appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + appHost.Services.AddLogging(logging => + { + logging.SetMinimumLevel(LogLevel.Debug); + // Override the logging filters from the app's configuration + logging.AddFilter(appHost.Environment.ApplicationName, LogLevel.Debug); + logging.AddFilter("Aspire.", LogLevel.Debug); + }); + appHost.Services.ConfigureHttpClientDefaults(clientBuilder => + { + clientBuilder.AddStandardResilienceHandler(); + }); + + await using var app = await appHost.BuildAsync(cancellationToken).WaitAsync(DefaultTimeout, cancellationToken); + await app.StartAsync(cancellationToken).WaitAsync(DefaultTimeout, cancellationToken); + + // Act + using var httpClient = app.CreateHttpClient("imagemapper-web"); + await app.ResourceNotifications.WaitForResourceHealthyAsync("imagemapper-web", cancellationToken).WaitAsync(DefaultTimeout, cancellationToken); + using var response = await httpClient.GetAsync("/", cancellationToken); + + // Assert + Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + } + } +}