Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix globalization tests to work with setting customization #24052

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class NumberFormatInfoCurrencyDecimalDigits
public static IEnumerable<object[]> CurrencyDecimalDigits_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, 2, 2 };
yield return new object[] { new CultureInfo("en-US").NumberFormat, 2, 2 };
yield return new object[] { new CultureInfo("ko").NumberFormat, 0, 2 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 2, 2 };
yield return new object[] { CultureInfo.GetCultureInfo("ko").NumberFormat, 0, 2 };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class NumberFormatInfoCurrencyGroupSizes
public static IEnumerable<object[]> CurrencyGroupSizes_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } };
yield return new object[] { new CultureInfo("en-US").NumberFormat, new int[] { 3 } };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } };

if ((!PlatformDetection.IsUbuntu || PlatformDetection.IsUbuntu1404)
&& !PlatformDetection.IsWindows7 && !PlatformDetection.IsWindows8x && !PlatformDetection.IsFedora)
{
yield return new object[] { new CultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 } };
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 } };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NumberFormatInfoCurrencyNegativePattern
public static IEnumerable<object[]> CurrencyNegativePattern_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 0 } };
yield return new object[] { new CultureInfo("bg-BG").NumberFormat, new int[] { 8 } };
yield return new object[] { CultureInfo.GetCultureInfo("bg-BG").NumberFormat, new int[] { 8 } };
}

[Theory]
Expand All @@ -36,7 +36,7 @@ public void CurrencyNegativePattern_Get(string locale)
CultureInfo culture;
try
{
culture = new CultureInfo(locale);
culture = CultureInfo.GetCultureInfo(locale);
}
catch(CultureNotFoundException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NumberFormatInfoCurrencyPositivePattern
public static IEnumerable<object[]> CurrencyPositivePattern_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, 0 };
yield return new object[] { new CultureInfo("en-US").NumberFormat, 0 };
yield return new object[] { new CultureInfo("fr-FR").NumberFormat, 3 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 0 };
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").NumberFormat, 3 };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class NumberFormatInfoCurrencySymbol
[InlineData("", "\x00a4")] // international
public void CurrencySymbol_Get(string name, string expected)
{
Assert.Equal(expected, new CultureInfo(name).NumberFormat.CurrencySymbol);
Assert.Equal(expected, CultureInfo.GetCultureInfo(name).NumberFormat.CurrencySymbol);
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NumberFormatInfoCurrentInfo : RemoteExecutorTestBase
{
public static IEnumerable<object[]> CurrentInfo_CustomCulture_TestData()
{
yield return new object[] { new CultureInfo("en") };
yield return new object[] { new CultureInfo("en-US") };
yield return new object[] { CultureInfo.GetCultureInfo("en") };
yield return new object[] { CultureInfo.GetCultureInfo("en-US") };
yield return new object[] { CultureInfo.InvariantCulture };
}

Expand All @@ -23,7 +23,7 @@ public void CurrentInfo_CustomCulture(CultureInfo newCurrentCulture)
{
RemoteInvoke((cultureName) =>
{
CultureInfo newCulture = new CultureInfo(cultureName);
CultureInfo newCulture = CultureInfo.GetCultureInfo(cultureName);
CultureInfo.CurrentCulture = newCulture;
Assert.Same(newCulture.NumberFormat, NumberFormatInfo.CurrentInfo);
return SuccessExitCode;
Expand Down Expand Up @@ -56,7 +56,7 @@ private class CultureInfoSubclassOverridesGetFormat : CultureInfo
{
public CultureInfoSubclassOverridesGetFormat(string name): base(name) { }

public static NumberFormatInfo CustomFormat { get; } = new CultureInfo("fr-FR").NumberFormat;
public static NumberFormatInfo CustomFormat { get; } = CultureInfo.GetCultureInfo("fr-FR").NumberFormat;

public override object GetFormat(Type formatType) => CustomFormat;
}
Expand All @@ -65,7 +65,7 @@ private class CultureInfoSubclassOverridesNumberFormat : CultureInfo
{
public CultureInfoSubclassOverridesNumberFormat(string name): base(name) { }

public static NumberFormatInfo CustomFormat { get; } = new CultureInfo("fr-FR").NumberFormat;
public static NumberFormatInfo CustomFormat { get; } = CultureInfo.GetCultureInfo("fr-FR").NumberFormat;

public override NumberFormatInfo NumberFormat
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal static int[] GetCurrencyNegativePatterns(string localeName)
return PlatformDetection.IsWindows ? new int[] { 15 } : new int[] { 8, 15 };
}

throw DateTimeFormatInfoData.GetCultureNotSupportedException(new CultureInfo(localeName));
throw DateTimeFormatInfoData.GetCultureNotSupportedException(CultureInfo.GetCultureInfo(localeName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class NumberFormatInfoGetInstance
{
public static IEnumerable<object[]> GetInstance_TestData()
{
CultureInfo frFRCulture = new CultureInfo("fr-FR");
CultureInfo frFRCulture = CultureInfo.GetCultureInfo("fr-FR");
yield return new object[] { frFRCulture, frFRCulture.NumberFormat };
yield return new object[] { frFRCulture.NumberFormat, frFRCulture.NumberFormat };
yield return new object[] { new CustomFormatProvider(), CustomFormatProvider.CustomFormat };
Expand Down Expand Up @@ -55,7 +55,7 @@ public void GetInstance(IFormatProvider formatProvider, NumberFormatInfo expecte

private class CustomFormatProvider : IFormatProvider
{
public static NumberFormatInfo CustomFormat { get; } = new CultureInfo("fr-FR").NumberFormat;
public static NumberFormatInfo CustomFormat { get; } = CultureInfo.GetCultureInfo("fr-FR").NumberFormat;

public object GetFormat(Type formatType) => CustomFormat;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NumberFormatInfoNegativeInfinitySymbol
public static IEnumerable<object[]> NegativeInfinitySymbol_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo };
yield return new object[] { new CultureInfo("en-US").NumberFormat };
yield return new object[] { new CultureInfo("fr-FR").NumberFormat };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat };
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").NumberFormat };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NumberFormatInfoNegativeSign
public static IEnumerable<object[]> NegativeSign_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, "-" };
yield return new object[] { new CultureInfo("en-US").NumberFormat, "-" };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, "-" };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NumberFormatInfoNumberDecimalDigits
public static IEnumerable<object[]> NumberDecimalDigits_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, 2, 2 };
yield return new object[] { new CultureInfo("en-US").NumberFormat, 2, 3 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 2, 3 };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class NumberFormatInfoNumberGroupSizes
public static IEnumerable<object[]> NumberGroupSizes_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } };
yield return new object[] { new CultureInfo("en-US").NumberFormat, new int[] { 3 } };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } };

// Culture does not exist on Windows 7
if (!PlatformDetection.IsWindows7)
{
yield return new object[] { new CultureInfo("ur-IN").NumberFormat, NumberFormatInfoData.UrINNumberGroupSizes() };
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, NumberFormatInfoData.UrINNumberGroupSizes() };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NumberFormatInfoNumberNegativePattern
public static IEnumerable<object[]> NumberNegativePattern_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, 1 };
yield return new object[] { new CultureInfo("en-US").NumberFormat, 1 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 1 };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NumberFormatInfoPercentGroupSizes
public static IEnumerable<object[]> PercentGroupSizes_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } };
yield return new object[] { new CultureInfo("en-US").NumberFormat, new int[] { 3 } };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class NumberFormatInfoPercentNegativePattern
{
public static IEnumerable<object[]> PercentNegativePattern_TestData()
{
yield return new object[] { new CultureInfo("en-US").NumberFormat, 1 };
yield return new object[] { new CultureInfo("en-MY").NumberFormat, 1 };
yield return new object[] { new CultureInfo("tr").NumberFormat, 2 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 1 };
yield return new object[] { CultureInfo.GetCultureInfo("en-MY").NumberFormat, 1 };
yield return new object[] { CultureInfo.GetCultureInfo("tr").NumberFormat, 2 };
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class NumberFormatInfoPercentPositivePattern
{
public static IEnumerable<object[]> PercentPositivePattern_TestData()
{
yield return new object[] { new CultureInfo("en-US").NumberFormat, 1 };
yield return new object[] { new CultureInfo("en-MY").NumberFormat, 1 };
yield return new object[] { new CultureInfo("tr").NumberFormat, 2 };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 1 };
yield return new object[] { CultureInfo.GetCultureInfo("en-MY").NumberFormat, 1 };
yield return new object[] { CultureInfo.GetCultureInfo("tr").NumberFormat, 2 };
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NumberFormatInfoPercentSymbol
public static IEnumerable<object[]> PercentSymbol_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, "%" };
yield return new object[] { new CultureInfo("en-US").NumberFormat, "%" };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, "%" };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NumberFormatInfoPositiveInfinitySymbol
public static IEnumerable<object[]> PositiveInfinitySymbol_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo };
yield return new object[] { new CultureInfo("en-US").NumberFormat };
yield return new object[] { new CultureInfo("fr-FR").NumberFormat };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat };
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").NumberFormat };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NumberFormatInfoPositiveSign
public static IEnumerable<object[]> PositiveSign_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, "+" };
yield return new object[] { new CultureInfo("en-US").NumberFormat, "+" };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, "+" };
}

[Theory]
Expand Down