forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Culture Native and Display Names (dotnet#53468)
* Fix Culture Native and Display Names * fix mono break * Address the feedback * Address more feedback * Use ThreadCultureChange in the tests * Exclude the test on mobile platfoms
- Loading branch information
Showing
8 changed files
with
126 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Tests; | ||
using Xunit; | ||
|
||
namespace System.Globalization.Tests | ||
{ | ||
public class CultureInfoNames | ||
{ | ||
private static bool SupportFullIcuResources => PlatformDetection.IsNotMobile && PlatformDetection.IsIcuGlobalization; | ||
|
||
[ConditionalTheory(nameof(SupportFullIcuResources))] | ||
[InlineData("en", "en", "English", "English")] | ||
[InlineData("en", "fr", "English", "anglais")] | ||
[InlineData("aa", "aa", "Afar", "Afar")] | ||
[InlineData("en-US", "en-US", "English (United States)", "English (United States)")] | ||
[InlineData("en-US", "fr-FR", "English (United States)", "anglais (États-Unis)")] | ||
[InlineData("en-US", "de-DE", "English (United States)", "Englisch (Vereinigte Staaten)")] | ||
[InlineData("aa-ER", "aa-ER", "Afar (Eritrea)", "Afar (Eritrea)")] | ||
[InlineData("", "en-US", "Invariant Language (Invariant Country)", "Invariant Language (Invariant Country)")] | ||
[InlineData("", "fr-FR", "Invariant Language (Invariant Country)", "Invariant Language (Invariant Country)")] | ||
[InlineData("", "", "Invariant Language (Invariant Country)", "Invariant Language (Invariant Country)")] | ||
public void TestDisplayName(string cultureName, string uiCultureName, string nativeName, string displayName) | ||
{ | ||
using (new ThreadCultureChange(null, CultureInfo.GetCultureInfo(uiCultureName))) | ||
{ | ||
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName); | ||
Assert.Equal(nativeName, ci.NativeName); | ||
Assert.Equal(displayName, ci.DisplayName); | ||
} | ||
} | ||
|
||
[ConditionalFact(nameof(SupportFullIcuResources))] | ||
public void TestDisplayNameWithSettingUICultureMultipleTime() | ||
{ | ||
using (new ThreadCultureChange(null, CultureInfo.GetCultureInfo("en-US"))) | ||
{ | ||
CultureInfo ci = new CultureInfo("en-US"); | ||
Assert.Equal("English (United States)", ci.DisplayName); | ||
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("fr-FR"); | ||
Assert.Equal("anglais (États-Unis)", ci.DisplayName); | ||
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE"); | ||
Assert.Equal("Englisch (Vereinigte Staaten)", ci.DisplayName); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.