Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Get Shell By Case Insensitive Name. #12120

33 changes: 8 additions & 25 deletions test/OrchardCore.Tests/Shell/ShellHostTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Environment.Shell;
Expand All @@ -19,15 +18,12 @@ public ShellHostTests()
}

[Theory]
[InlineData("Test")]
[InlineData("orchardcore")]
[InlineData(ShellHelper.DefaultShellName)]

public async Task FindCaseInsensitiveShellSettings(string shellName)
[InlineData("Test", "test")]
[InlineData("OrchardCore", "orchardcore")]
[InlineData(ShellHelper.DefaultShellName, "DeFauLt")]
public async Task FindCaseInsensitiveShellSettings(string shellName, string anotherVariantOfShellName)
{
await GetOrCreateShellContextAsync(shellName);
var anotherVariantOfShellName = GetDifferentVariant(shellName);

_shellHost.TryGetSettings(shellName, out var shellSettings);
_shellHost.TryGetSettings(anotherVariantOfShellName, out var anotherVariantOfShellSettings);

Expand All @@ -38,13 +34,12 @@ public async Task FindCaseInsensitiveShellSettings(string shellName)
}
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved

[Theory]
[InlineData("Test")]
[InlineData("orchardcore")]
[InlineData(ShellHelper.DefaultShellName)]
public async Task FindCaseInsensitiveShellContext(string shellName)
[InlineData("Test", "test")]
[InlineData("OrchardCore", "orchardcore")]
[InlineData(ShellHelper.DefaultShellName, "dEfAut")]
public async Task FindCaseInsensitiveShellContext(string shellName, string anotherVariantOfShellName)
{
await GetOrCreateShellContextAsync(shellName);
var anotherVariantOfShellName = GetDifferentVariant(shellName);

_shellHost.TryGetShellContext(shellName, out var shellContext);
_shellHost.TryGetShellContext(anotherVariantOfShellName, out var anotherVariantOfShellContext);
Expand All @@ -65,16 +60,4 @@ private async Task<ShellContext> GetOrCreateShellContextAsync(string name)

return await _shellHost.GetOrCreateShellContextAsync(shellSettings);
}

private static string GetDifferentVariant(string name)
{
var caps = name.ToUpper(CultureInfo.InvariantCulture);

if (caps == name)
{
return name.ToLower(CultureInfo.InvariantCulture);
}

return caps;
}
}
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved