diff --git a/backend/Directory.Packages.props b/backend/Directory.Packages.props index 5f6fea1b..20e77741 100644 --- a/backend/Directory.Packages.props +++ b/backend/Directory.Packages.props @@ -10,6 +10,7 @@ + diff --git a/backend/RateMyPet.slnx b/backend/RateMyPet.slnx index 194cdb80..f792547e 100644 --- a/backend/RateMyPet.slnx +++ b/backend/RateMyPet.slnx @@ -9,6 +9,7 @@ + diff --git a/backend/tests/AppHost.Tests/AppHost.Tests.csproj b/backend/tests/AppHost.Tests/AppHost.Tests.csproj new file mode 100644 index 00000000..b1c81cd0 --- /dev/null +++ b/backend/tests/AppHost.Tests/AppHost.Tests.csproj @@ -0,0 +1,24 @@ + + + + false + true + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/backend/tests/AppHost.Tests/AppHostFixture.cs b/backend/tests/AppHost.Tests/AppHostFixture.cs new file mode 100644 index 00000000..86dc9ca4 --- /dev/null +++ b/backend/tests/AppHost.Tests/AppHostFixture.cs @@ -0,0 +1,16 @@ +using Aspire.Hosting; +using Aspire.Hosting.Testing; +using Microsoft.Extensions.Hosting; +using RateMyPet.AppHost.Tests; + +[assembly: AssemblyFixture(typeof(AppHostFixture))] + +namespace RateMyPet.AppHost.Tests; + +public sealed class AppHostFixture() : DistributedApplicationFactory(typeof(Projects.AppHost)), IAsyncLifetime +{ + public async ValueTask InitializeAsync() + { + await StartAsync(); + } +} diff --git a/backend/tests/AppHost.Tests/GlobalUsings.cs b/backend/tests/AppHost.Tests/GlobalUsings.cs new file mode 100644 index 00000000..f644bd9c --- /dev/null +++ b/backend/tests/AppHost.Tests/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Shouldly; +global using Xunit; diff --git a/backend/tests/AppHost.Tests/HealthEndpointTests.cs b/backend/tests/AppHost.Tests/HealthEndpointTests.cs new file mode 100644 index 00000000..71b3c5e4 --- /dev/null +++ b/backend/tests/AppHost.Tests/HealthEndpointTests.cs @@ -0,0 +1,19 @@ +using System.Net; + +namespace RateMyPet.AppHost.Tests; + +public class HealthEndpointTests(AppHostFixture fixture) +{ + [Fact] + public async Task GetHealth_Should_ReturnOk() + { + // arrange + var httpClient = fixture.CreateHttpClient("api"); + + // act + var response = await httpClient.GetAsync("/health", TestContext.Current.CancellationToken); + + // assert + response.StatusCode.ShouldBe(HttpStatusCode.OK); + } +}