Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using Microsoft.Extensions.Logging;

namespace Aspire.Tests._1;

[TestClass]
public class IntegrationTest1
{
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);

// Instructions:
// 1. Add a project reference to the target AppHost project, e.g.:
//
Expand All @@ -17,19 +21,26 @@ public class IntegrationTest1
// {
// // Arrange
// var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.MyAspireApp_AppHost>();
// 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();
// var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
// await app.StartAsync();

//
// await using var app = await appHost.BuildAsync().WaitAsync(DefaultTimeout);
// await app.StartAsync().WaitAsync(DefaultTimeout);
//
// // Act
// var httpClient = app.CreateHttpClient("webfrontend");
// await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
// await app.ResourceNotifications.WaitForResourceHealthyAsync("webfrontend").WaitAsync(DefaultTimeout);
// var response = await httpClient.GetAsync("/");

//
// // Assert
// Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Microsoft.Extensions.Logging;

namespace Aspire.Tests._1;

public class IntegrationTest1
{
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);

// Instructions:
// 1. Add a project reference to the target AppHost project, e.g.:
//
Expand All @@ -16,19 +20,26 @@ public class IntegrationTest1
// {
// // Arrange
// var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.MyAspireApp_AppHost>();
// 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();
// var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
// await app.StartAsync();

//
// await using var app = await appHost.BuildAsync().WaitAsync(DefaultTimeout);
// await app.StartAsync().WaitAsync(DefaultTimeout);
//
// // Act
// var httpClient = app.CreateHttpClient("webfrontend");
// await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
// await app.ResourceNotifications.WaitForResourceHealthyAsync("webfrontend").WaitAsync(DefaultTimeout);
// var response = await httpClient.GetAsync("/");

//
// // Assert
// Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using Microsoft.Extensions.Logging;

namespace Aspire_StarterApplication._1.Tests;

#if (TestFramework == "MSTest")
[TestClass]
#endif
public class WebTests
{
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);

#if (TestFramework == "MSTest")
[TestMethod]
#elif (TestFramework == "NUnit")
Expand All @@ -16,21 +20,27 @@ public async Task GetWebResourceRootReturnsOkStatusCode()
{
// Arrange
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.GeneratedClassNamePrefix_AppHost>();
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);
#if (TestFramework == "xUnit.net")
// To output logs to the xUnit.net ITestOutputHelper, consider adding a package from https://www.nuget.org/packages?q=xunit+logging
#endif
});
appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
{
clientBuilder.AddStandardResilienceHandler();
});
#if (TestFramework == "xUnit.net")
// To output logs to the xUnit.net ITestOutputHelper, consider adding a package from https://www.nuget.org/packages?q=xunit+logging
#endif

await using var app = await appHost.BuildAsync();
var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
await app.StartAsync();
await using var app = await appHost.BuildAsync().WaitAsync(DefaultTimeout);
await app.StartAsync().WaitAsync(DefaultTimeout);

// Act
var httpClient = app.CreateHttpClient("webfrontend");
await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
await app.ResourceNotifications.WaitForResourceHealthyAsync("webfrontend").WaitAsync(DefaultTimeout);
var response = await httpClient.GetAsync("/");

// Assert
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Microsoft.Extensions.Logging;

namespace Aspire.Tests._1.Tests;

public class IntegrationTest1
{
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);

// Instructions:
// 1. Add a project reference to the target AppHost project, e.g.:
//
Expand All @@ -16,21 +20,27 @@ public class IntegrationTest1
// {
// // Arrange
// var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.MyAspireApp_AppHost>();
// 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);
// // To output logs to the xUnit.net ITestOutputHelper, consider adding a package from https://www.nuget.org/packages?q=xunit+logging
// });
// 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();

// await using var app = await appHost.BuildAsync().WaitAsync(DefaultTimeout);
// await app.StartAsync().WaitAsync(DefaultTimeout);
//
// // Act
// var httpClient = app.CreateHttpClient("webfrontend");
// await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
// await app.ResourceNotifications.WaitForResourceHealthyAsync("webfrontend").WaitAsync(DefaultTimeout);
// var response = await httpClient.GetAsync("/");

//
// // Assert
// Assert.Equal(HttpStatusCode.OK, response.StatusCode);
// }
Expand Down