/* * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) * See https://github.com/openiddict/openiddict-core for more information concerning * the license and the contributors participating to this project. */ using Microsoft.AspNetCore.TestHost; using OpenIddict.Validation.IntegrationTests; #if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST using Microsoft.Extensions.Hosting; #endif namespace OpenIddict.Validation.AspNetCore.IntegrationTests; /// /// Represents a test host used by the validation integration tests. /// public class OpenIddictValidationAspNetCoreIntegrationTestServer : OpenIddictValidationIntegrationTestServer { #if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST public OpenIddictValidationAspNetCoreIntegrationTestServer(IHost host) { Host = host; Server = host.GetTestServer(); } /// /// Gets the generic host used by this instance. /// public IHost Host { get; } #else public OpenIddictValidationAspNetCoreIntegrationTestServer(TestServer server) => Server = server; #endif /// /// Gets the ASP.NET Core test server used by this instance. /// public TestServer Server { get; } public override ValueTask CreateClientAsync() => new(new OpenIddictValidationIntegrationTestClient(Server.CreateClient())); public override #if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST async #endif ValueTask DisposeAsync() { // Dispose of the underlying test server. Server.Dispose(); #if SUPPORTS_WEB_INTEGRATION_IN_GENERIC_HOST // Stop and dispose of the underlying generic host. await Host.StopAsync(); Host.Dispose(); #else return default; #endif } }