-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c07d088
commit 4ffa137
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps.Tests/SwaHostingComponentTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using CommunityToolkit.Aspire.Testing; | ||
using FluentAssertions; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using Xunit.Abstractions; | ||
|
||
namespace CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps.Tests; | ||
|
||
public class SwaHostingComponentTests(ITestOutputHelper testOutput) : AspireIntegrationTest<Projects.CommunityToolkit_Aspire_StaticWebApps_AppHost>(testOutput) | ||
{ | ||
[Fact] | ||
public async Task EmulatorLaunchesOnDefaultPort() | ||
{ | ||
var httpClient = app.CreateHttpClient("swa"); | ||
|
||
await ResourceNotificationService.WaitForResourceAsync("swa", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30)); | ||
|
||
var response = await httpClient.GetAsync("/"); | ||
|
||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
} | ||
|
||
[Fact] | ||
public async Task CanAccessApi() | ||
{ | ||
var httpClient = app.CreateHttpClient("swa"); | ||
|
||
await ResourceNotificationService.WaitForResourceAsync("swa", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30)); | ||
|
||
var response = await httpClient.GetAsync("/api/weather"); | ||
|
||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
var forecasts = await response.Content.ReadFromJsonAsync<WeatherForecast[]>(); | ||
Assert.NotNull(forecasts); | ||
forecasts.Length.Should().Be(6); | ||
} | ||
|
||
record WeatherForecast(DateTime Date, int TemperatureC, string Summary); | ||
} |