ResourceManagerStringLocalizerTest: support running tests under the invariant culture. (#51935)

This commit is contained in:
Tom Deseyn 2023-11-08 22:20:48 +01:00 коммит произвёл GitHub
Родитель b0042229da
Коммит f884a7b6b1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -199,10 +199,12 @@ public class ResourceManagerStringLocalizerTest
#pragma warning restore CA1304 // Specify CultureInfo
});
var expectedTries = includeParentCultures ? 3 : 1;
var expectedTries = includeParentCultures ? GetCultureInfoDepth(CultureInfo.CurrentUICulture) : 1;
string cultureName = CultureInfo.CurrentCulture.ToString();
string expectedManifestFileName = cultureName.Length > 0 ? $"testington.{cultureName}.resources" : $"testington.resources";
var expected = includeParentCultures
? "No manifests exist for the current culture."
: $"The manifest 'testington.{CultureInfo.CurrentCulture}.resources' was not found.";
: $"The manifest '{expectedManifestFileName}' was not found.";
Assert.Equal(expected, exception.Message);
Assert.Equal(expectedTries, resourceAssembly.ManifestResourceStreamCallCount);
}
@ -226,7 +228,10 @@ public class ResourceManagerStringLocalizerTest
{
result++;
if (currentCulture == currentCulture.Parent)
// Under LC_ALL=C on Linux, the current culture is an invariant culture, but its Parent does
// not refer to itself (https://github.com/dotnet/runtime/issues/94505).
// Avoid counting it as 2 cultures by directly checking for equality against the InvariantCulture.
if (CultureInfo.InvariantCulture.Equals(currentCulture))
{
break;
}