-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dapr-redis-ext-fixes
- Loading branch information
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
examples/mailpit/CommunityToolkit.Aspire.Hosting.MailPit.AppHost/Program.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
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
40 changes: 40 additions & 0 deletions
40
tests/CommunityToolkit.Aspire.Hosting.MailPit.Tests/AppHostHealthChecksTests.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,40 @@ | ||
using Aspire.Components.Common.Tests; | ||
using Aspire.Hosting; | ||
using CommunityToolkit.Aspire.Testing; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using System.Security.Cryptography; | ||
|
||
namespace CommunityToolkit.Aspire.Hosting.MailPit.Tests; | ||
|
||
[RequiresDocker] | ||
public sealed class AppHostHealthChecksTests(AppHostHealthChecksTests.MailPitAspireIntegrationTestFixture<Projects.CommunityToolkit_Aspire_Hosting_MailPit_AppHost> fixture) | ||
: IClassFixture<AppHostHealthChecksTests.MailPitAspireIntegrationTestFixture<Projects.CommunityToolkit_Aspire_Hosting_MailPit_AppHost>> | ||
{ | ||
private const string ResourceName = "mailpit"; | ||
|
||
[Fact] | ||
public async Task ResourceStartsHealthyUsingCustomHttpPort() | ||
{ | ||
await fixture.ResourceNotificationService | ||
.WaitForResourceHealthyAsync(ResourceName) | ||
.WaitAsync(TimeSpan.FromMinutes(1)); | ||
} | ||
|
||
public sealed class MailPitAspireIntegrationTestFixture<TEntryPoint>() | ||
: AspireIntegrationTestFixture<TEntryPoint> where TEntryPoint : class | ||
{ | ||
protected override void OnBuilderCreated(DistributedApplicationBuilder applicationBuilder) | ||
{ | ||
base.OnBuilderCreated(applicationBuilder); | ||
applicationBuilder.Configuration.AddInMemoryCollection([ | ||
new KeyValuePair<string, string?>("MailPit:HttpPort", $"{GetRandomPort()}"), | ||
]); | ||
} | ||
|
||
private static int GetRandomPort() | ||
{ | ||
return RandomNumberGenerator.GetInt32(1024, 65535); | ||
} | ||
} | ||
} |