Repository: dotnet/aspnetcore
File: src/Components/WebAssembly/WebAssembly/test/Hosting/WebAssemblyCultureProviderTest.cs (C#)

Code before:
using Microsoft.AspNetCore.InternalTesting;

namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting;

public class WebAssemblyCultureProviderTest
{
    [Theory]
    [InlineData("fr-FR", new[] { "fr-FR", "fr" })]
    [InlineData("tzm-Latn-DZ", new[] { "tzm-Latn-DZ", "tzm-Latn", "tzm" })]
    public void GetCultures_ReturnsCultureClosure(string cultureName, string[] expected)
    {
        // Arrange
        var culture = new CultureInfo(cultureName);

        // Act
        var actual = WebAssemblyCultureProvider.GetCultures(culture);

        // Assert
        Assert.Equal(expected, actual);
    }

    [Theory]
    [InlineData("fr-FR", "tzm-Latn-DZ", new[] { "fr-FR", "fr", "tzm-Latn-DZ", "tzm-Latn", "tzm" })]
    [InlineData("en-US", "en-GB", new[] { "en-US", "en", "en-GB" })]
    [InlineData("fr-FR", null, new[] { "fr-FR", "fr" })]
    [InlineData(null, null, new string[0])]
    public void GetCultures_ReturnCultureClosureWithUICulture(string cultureName, string uiCultureName, string[] expected)
    {
        // Arrange
        var culture = cultureName != null ? new CultureInfo(cultureName) : null;
        var uiCulture = uiCultureName != null ? new CultureInfo(uiCultureName) : null;
        // Act
        var actual = WebAssemblyCultureProvider.GetCultures(culture, uiCulture);
        // Assert
        Assert.Equal(expected, actual);
    }

    [Fact]
    public void ThrowIfCultureChangeIsUnsupported_ThrowsIfCulturesAreDifferentAndICUShardingIsUsed()
    {
        // Arrange
        Environment.SetEnvironmentVariable("__BLAZOR_SHARDED_ICU", "1");
        try
        {
            // WebAssembly is initialized with en-US
            var cultureProvider = new WebAssemblyCultureProvider(new CultureInfo("en-US"), new CultureInfo("en-US"));

            // Culture is changed to fr-FR as part of the app
            using var cultureReplacer = new CultureReplacer("fr-FR");

            var ex = Assert.Throws<InvalidOperationException>(() => cultureProvider.ThrowIfCultureChangeIsUnsupported());

Review comment (suggestion):
After the last commit, double `null` `InlineData` can be removed, `cultureInfo` cannot be null:
`internal static string[] GetCultures(CultureInfo cultureInfo, CultureInfo? uiCultureInfo = null)`

Code after:
using Microsoft.AspNetCore.InternalTesting;

namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting;

public class WebAssemblyCultureProviderTest
{
    [Theory]
    [InlineData("fr-FR", new[] { "fr-FR", "fr" })]
    [InlineData("tzm-Latn-DZ", new[] { "tzm-Latn-DZ", "tzm-Latn", "tzm" })]
    public void GetCultures_ReturnsCultureClosure(string cultureName, string[] expected)
    {
        // Arrange
        var culture = new CultureInfo(cultureName);

        // Act
        var actual = WebAssemblyCultureProvider.GetCultures(culture);

        // Assert
        Assert.Equal(expected, actual);
    }

    [Theory]
    [InlineData("fr-FR", "tzm-Latn-DZ", new[] { "fr-FR", "fr", "tzm-Latn-DZ", "tzm-Latn", "tzm" })]
    [InlineData("en-US", "en-GB", new[] { "en-US", "en", "en-GB" })]
    [InlineData("fr-FR", null, new[] { "fr-FR", "fr" })]
    public void GetCultures_ReturnCultureClosureWithUICulture(string cultureName, string uiCultureName, string[] expected)
    {
        // Arrange
        var culture = cultureName != null ? new CultureInfo(cultureName) : null;
        var uiCulture = uiCultureName != null ? new CultureInfo(uiCultureName) : null;
        // Act
        var actual = WebAssemblyCultureProvider.GetCultures(culture, uiCulture);
        // Assert
        Assert.Equal(expected, actual);
    }

    [Fact]
    public void ThrowIfCultureChangeIsUnsupported_ThrowsIfCulturesAreDifferentAndICUShardingIsUsed()
    {
        // Arrange
        Environment.SetEnvironmentVariable("__BLAZOR_SHARDED_ICU", "1");
        try
        {
            // WebAssembly is initialized with en-US
            var cultureProvider = new WebAssemblyCultureProvider(new CultureInfo("en-US"), new CultureInfo("en-US"));

            // Culture is changed to fr-FR as part of the app
            using var cultureReplacer = new CultureReplacer("fr-FR");

            var ex = Assert.Throws<InvalidOperationException>(() => cultureProvider.ThrowIfCultureChangeIsUnsupported());
            Assert.Equal("Blazor detected a change in the application's culture that is not supported with the current project configuration. " +