Scaffold Aspire starter app
This commit is contained in:
32
PresentPortal.Tests/PresentPortal.Tests.csproj
Normal file
32
PresentPortal.Tests/PresentPortal.Tests.csproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspire.Hosting.Testing" Version="9.0.0"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
|
||||
<PackageReference Include="xunit" Version="2.9.0"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PresentPortal.AppHost\PresentPortal.AppHost.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System.Net"/>
|
||||
<Using Include="Microsoft.Extensions.DependencyInjection"/>
|
||||
<Using Include="Aspire.Hosting.ApplicationModel"/>
|
||||
<Using Include="Aspire.Hosting.Testing"/>
|
||||
<Using Include="Xunit"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
29
PresentPortal.Tests/WebTests.cs
Normal file
29
PresentPortal.Tests/WebTests.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace PresentPortal.Tests;
|
||||
|
||||
public class WebTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetWebResourceRootReturnsOkStatusCode()
|
||||
{
|
||||
// Arrange
|
||||
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.PresentPortal_AppHost>();
|
||||
appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
|
||||
{
|
||||
clientBuilder.AddStandardResilienceHandler();
|
||||
});
|
||||
// To output logs to the xUnit.net ITestOutputHelper, consider adding a package from https://www.nuget.org/packages?q=xunit+logging
|
||||
|
||||
await using var app = await appHost.BuildAsync();
|
||||
var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
|
||||
await app.StartAsync();
|
||||
|
||||
// Act
|
||||
var httpClient = app.CreateHttpClient("webfrontend");
|
||||
await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running)
|
||||
.WaitAsync(TimeSpan.FromSeconds(30));
|
||||
var response = await httpClient.GetAsync("/");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user