From 13e5f4e8bf8d377cc2954c5883c0e9ea6d9a5c05 Mon Sep 17 00:00:00 2001 From: Aydin Erdas Date: Fri, 10 May 2024 10:25:54 +0200 Subject: [PATCH] GetTenantOptionsAsync --- .../ShortcutsUITestContextExtensions.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs index e99b64b9e..4aaf99d23 100644 --- a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using OpenQA.Selenium; using OrchardCore.Abstractions.Setup; using OrchardCore.Admin; @@ -602,6 +603,28 @@ await UsingScopeAsync( return eventUrl; } + /// + /// Retrieves the options of the given type from the current tenant's shell scope. + /// + public static async Task> GetTenantOptionsAsync( + this UITestContext context, + string tenant = null, + bool activateShell = true) + where T : class + { + IOptions options = null; + await UsingScopeAsync( + context, + serviceProvider => + { + options = serviceProvider.GetRequiredService>(); + return Task.CompletedTask; + }, + tenant, + activateShell); + return options; + } + /// /// Switches to an interactive mode where control from the test is handed over and you can use the web app as an /// ordinary user from the browser or access its web APIs. To switch back to the test, click the button