From 699887ff50d36ed54e80febd4c2b50e31d554ee5 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Tue, 16 May 2017 15:24:18 -0700 Subject: [PATCH] Fixed uap/uapaot tests in System.Runtime (#19819) * Fixed uap/uapaot tests in System.Runtime * Remove Collection --- .../System/Reflection/AssemblyNameTests.cs | 2 +- .../tests/System/Reflection/AssemblyTests.cs | 140 +++++++++--------- .../tests/System/StringTests.cs | 40 +++-- 3 files changed, 87 insertions(+), 95 deletions(-) diff --git a/src/System.Runtime/tests/System/Reflection/AssemblyNameTests.cs b/src/System.Runtime/tests/System/Reflection/AssemblyNameTests.cs index 8769e20c2cdf..d3f64fd319f8 100644 --- a/src/System.Runtime/tests/System/Reflection/AssemblyNameTests.cs +++ b/src/System.Runtime/tests/System/Reflection/AssemblyNameTests.cs @@ -77,7 +77,7 @@ public static void Clone() } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "AssemblyName.GetAssemblyName() not supported on UapAot")] + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "AssemblyName.GetAssemblyName() not supported on UapAot")] public static void GetAssemblyName() { AssertExtensions.Throws("assemblyFile", () => AssemblyName.GetAssemblyName(null)); diff --git a/src/System.Runtime/tests/System/Reflection/AssemblyTests.cs b/src/System.Runtime/tests/System/Reflection/AssemblyTests.cs index f200d4dd660e..cc51e14081c2 100644 --- a/src/System.Runtime/tests/System/Reflection/AssemblyTests.cs +++ b/src/System.Runtime/tests/System/Reflection/AssemblyTests.cs @@ -23,28 +23,22 @@ namespace System.Reflection.Tests { - public class AssemblyTests + public class AssemblyTests : FileCleanupTestBase { + private string SourceTestAssemblyPath { get; } = Path.Combine(Environment.CurrentDirectory, "TestAssembly.dll"); + private string DestTestAssemblyPath { get; } + private string LoadFromTestPath { get; } - static string sourceTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "TestAssembly.dll"); - static string destTestAssemblyPath = Path.Combine(Environment.CurrentDirectory, "TestAssembly", "TestAssembly.dll"); - static string loadFromTestPath; - - static AssemblyTests() + public AssemblyTests() + : base() { - loadFromTestPath = null; -#if !uapaot // Assembly.Location not supported (properly) on uapaot. - // Move TestAssembly.dll to subfolder TestAssembly - Directory.CreateDirectory(Path.GetDirectoryName(destTestAssemblyPath)); - if (File.Exists(sourceTestAssemblyPath)) - { - File.Delete(destTestAssemblyPath); - File.Move(sourceTestAssemblyPath, destTestAssemblyPath); - } - string currAssemblyPath = typeof(AssemblyTests).Assembly.Location; - loadFromTestPath = Path.Combine(Path.GetDirectoryName(currAssemblyPath), "TestAssembly", Path.GetFileName(currAssemblyPath)); - File.Copy(currAssemblyPath, loadFromTestPath, true); -#endif + DestTestAssemblyPath = Path.Combine(base.TestDirectory, "TestAssembly.dll"); + File.Copy(SourceTestAssemblyPath, DestTestAssemblyPath); + + // Assembly.Location not supported (properly) on uapaot. + string currAssemblyPath = Path.Combine(Environment.CurrentDirectory, "System.Runtime.Tests.dll"); + LoadFromTestPath = Path.Combine(base.TestDirectory, "System.Runtime.Tests.dll"); + File.Copy(currAssemblyPath, LoadFromTestPath, true); } public static IEnumerable Equality_TestData() @@ -56,14 +50,14 @@ public static IEnumerable Equality_TestData() [Theory] [MemberData(nameof(Equality_TestData))] - public static void Equality(Assembly assembly1, Assembly assembly2, bool expected) + public void Equality(Assembly assembly1, Assembly assembly2, bool expected) { Assert.Equal(expected, assembly1 == assembly2); Assert.NotEqual(expected, assembly1 != assembly2); } [Fact] - public static void GetAssembly_Nullery() + public void GetAssembly_Nullery() { AssertExtensions.Throws("type", () => Assembly.GetAssembly(null)); } @@ -77,7 +71,7 @@ public static IEnumerable GetAssembly_TestData() [Theory] [MemberData(nameof(GetAssembly_TestData))] - public static void GetAssembly(Assembly assembly1, Assembly assembly2, bool expected) + public void GetAssembly(Assembly assembly1, Assembly assembly2, bool expected) { Assert.Equal(expected, assembly1.Equals(assembly2)); } @@ -91,20 +85,20 @@ public static IEnumerable GetCallingAssembly_TestData() [Theory] [MemberData(nameof(GetCallingAssembly_TestData))] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "GetCallingAssembly() is not supported on UapAot")] - public static void GetCallingAssembly(Assembly assembly1, Assembly assembly2, bool expected) + public void GetCallingAssembly(Assembly assembly1, Assembly assembly2, bool expected) { Assert.Equal(expected, assembly1.Equals(assembly2)); } [Fact] - public static void GetExecutingAssembly() + public void GetExecutingAssembly() { Assert.True(typeof(AssemblyTests).Assembly.Equals(Assembly.GetExecutingAssembly())); } [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.GetSatelliteAssembly() not supported on UapAot")] - public static void GetSatelliteAssemblyNeg() + public void GetSatelliteAssemblyNeg() { Assert.Throws(() => (typeof(AssemblyTests).Assembly.GetSatelliteAssembly(null))); Assert.Throws(() => (typeof(AssemblyTests).Assembly.GetSatelliteAssembly(CultureInfo.InvariantCulture))); @@ -112,7 +106,7 @@ public static void GetSatelliteAssemblyNeg() [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.Load(String) not supported on UapAot")] - public static void AssemblyLoadFromString() + public void AssemblyLoadFromString() { AssemblyName an = typeof(AssemblyTests).Assembly.GetName(); string fullName = an.FullName; @@ -128,7 +122,7 @@ public static void AssemblyLoadFromString() } [Fact] - public static void AssemblyLoadFromStringNeg() + public void AssemblyLoadFromStringNeg() { Assert.Throws(() => Assembly.Load((string)null)); Assert.Throws(() => Assembly.Load(string.Empty)); @@ -138,8 +132,8 @@ public static void AssemblyLoadFromStringNeg() } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] - public static void AssemblyLoadFromBytes() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] + public void AssemblyLoadFromBytes() { Assembly assembly = typeof(AssemblyTests).Assembly; byte[] aBytes = System.IO.File.ReadAllBytes(assembly.Location); @@ -150,16 +144,16 @@ public static void AssemblyLoadFromBytes() } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] - public static void AssemblyLoadFromBytesNeg() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] + public void AssemblyLoadFromBytesNeg() { Assert.Throws(() => Assembly.Load((byte[])null)); Assert.Throws(() => Assembly.Load(new byte[0])); } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] - public static void AssemblyLoadFromBytesWithSymbols() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.Load(byte[]) not supported on UapAot")] + public void AssemblyLoadFromBytesWithSymbols() { Assembly assembly = typeof(AssemblyTests).Assembly; byte[] aBytes = System.IO.File.ReadAllBytes(assembly.Location); @@ -170,23 +164,23 @@ public static void AssemblyLoadFromBytesWithSymbols() Assert.Equal(assembly.FullName, loadedAssembly.FullName); } - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] - public static void AssemblyReflectionOnlyLoadFromString() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] + public void AssemblyReflectionOnlyLoadFromString() { AssemblyName an = typeof(AssemblyTests).Assembly.GetName(); Assert.Throws(() => Assembly.ReflectionOnlyLoad(an.FullName)); } - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] - public static void AssemblyReflectionOnlyLoadFromBytes() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] + public void AssemblyReflectionOnlyLoadFromBytes() { Assembly assembly = typeof(AssemblyTests).Assembly; byte[] aBytes = System.IO.File.ReadAllBytes(assembly.Location); Assert.Throws(() => Assembly.ReflectionOnlyLoad(aBytes)); } - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] - public static void AssemblyReflectionOnlyLoadFromNeg() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.ReflectionOnlyLoad() not supported on UapAot")] + public void AssemblyReflectionOnlyLoadFromNeg() { Assert.Throws(() => Assembly.ReflectionOnlyLoad((string)null)); Assert.Throws(() => Assembly.ReflectionOnlyLoad(string.Empty)); @@ -203,7 +197,7 @@ public static IEnumerable GetModules_TestData() [Theory] [MemberData(nameof(GetModules_TestData))] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.GetModules() is not supported on UapAot.")] - public static void GetModules_GetModule(Assembly assembly) + public void GetModules_GetModule(Assembly assembly) { Assert.NotEmpty(assembly.GetModules()); foreach (Module module in assembly.GetModules()) @@ -214,7 +208,7 @@ public static void GetModules_GetModule(Assembly assembly) [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.GetLoadedModules() is not supported on UapAot.")] - public static void GetLoadedModules() + public void GetLoadedModules() { Assembly assembly = typeof(AssemblyTests).Assembly; Assert.NotEmpty(assembly.GetLoadedModules()); @@ -234,7 +228,7 @@ public static IEnumerable CreateInstance_TestData() [Theory] [MemberData(nameof(CreateInstance_TestData))] - public static void CreateInstance(Assembly assembly, string typeName, BindingFlags bindingFlags, Type expectedType) + public void CreateInstance(Assembly assembly, string typeName, BindingFlags bindingFlags, Type expectedType) { Assert.IsType(expectedType, assembly.CreateInstance(typeName, true, bindingFlags, null, null, null, null)); Assert.IsType(expectedType, assembly.CreateInstance(typeName, false, bindingFlags, null, null, null, null)); @@ -249,7 +243,7 @@ public static IEnumerable CreateInstance_Invalid_TestData() [Theory] [MemberData(nameof(CreateInstance_Invalid_TestData))] - public static void CreateInstance_Invalid(string typeName, Type exceptionType) + public void CreateInstance_Invalid(string typeName, Type exceptionType) { Assembly assembly = typeof(AssemblyTests).Assembly; Assert.Throws(exceptionType, () => assembly.CreateInstance(typeName, true, BindingFlags.Public, null, null, null, null)); @@ -257,7 +251,7 @@ public static void CreateInstance_Invalid(string typeName, Type exceptionType) } [Fact] - public static void GetManifestResourceStream() + public void GetManifestResourceStream() { Assert.NotNull(typeof(AssemblyTests).Assembly.GetManifestResourceStream(typeof(AssemblyTests), "EmbeddedImage.png")); Assert.NotNull(typeof(AssemblyTests).Assembly.GetManifestResourceStream(typeof(AssemblyTests), "EmbeddedTextFile.txt")); @@ -265,40 +259,40 @@ public static void GetManifestResourceStream() } [Fact] - public static void Test_GlobalAssemblyCache() + public void Test_GlobalAssemblyCache() { Assert.False(typeof(AssemblyTests).Assembly.GlobalAssemblyCache); } [Fact] - public static void Test_HostContext() + public void Test_HostContext() { Assert.Equal(0, typeof(AssemblyTests).Assembly.HostContext); } [Fact] - public static void Test_IsFullyTrusted() + public void Test_IsFullyTrusted() { Assert.True(typeof(AssemblyTests).Assembly.IsFullyTrusted); } [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "The full .NET Framework supports SecurityRuleSet")] - public static void Test_SecurityRuleSet_Netcore() + public void Test_SecurityRuleSet_Netcore() { Assert.Equal(SecurityRuleSet.None, typeof(AssemblyTests).Assembly.SecurityRuleSet); } [Fact] [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "SecurityRuleSet is ignored in .NET Core")] - public static void Test_SecurityRuleSet_Netfx() + public void Test_SecurityRuleSet_Netfx() { Assert.Equal(SecurityRuleSet.Level2, typeof(AssemblyTests).Assembly.SecurityRuleSet); } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.LoadFile() not supported on UapAot")] - public static void Test_LoadFile() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.LoadFile() not supported on UapAot")] + public void Test_LoadFile() { Assembly currentAssembly = typeof(AssemblyTests).Assembly; const string RuntimeTestsDll = "System.Runtime.Tests.dll"; @@ -329,36 +323,36 @@ public static void Test_LoadFile() } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot, "The full .NET Framework has a bug and throws a NullReferenceException")] - public static void LoadFile_NullPath_Netcore_ThrowsArgumentNullException() + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "The full .NET Framework has a bug and throws a NullReferenceException")] + public void LoadFile_NullPath_Netcore_ThrowsArgumentNullException() { AssertExtensions.Throws("path", () => Assembly.LoadFile(null)); } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.LoadFile() not supported on UapAot")] - public static void LoadFile_NoSuchPath_ThrowsArgumentException() + [SkipOnTargetFramework(TargetFrameworkMonikers.Uap | TargetFrameworkMonikers.UapAot, "Assembly.LoadFile() not supported on UapAot")] + public void LoadFile_NoSuchPath_ThrowsArgumentException() { Assert.Throws(() => Assembly.LoadFile("System.Runtime.Tests.dll")); } [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot, "The full .NET Framework supports Assembly.LoadFrom")] - public static void Test_LoadFromUsingHashValue_Netcore() + public void Test_LoadFromUsingHashValue_Netcore() { Assert.Throws(() => Assembly.LoadFrom("abc", null, System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA1)); } [Fact] [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "The implementation of Assembly.LoadFrom is stubbed out in .NET Core")] - public static void Test_LoadFromUsingHashValue_Netfx() + public void Test_LoadFromUsingHashValue_Netfx() { Assert.Throws(() => Assembly.LoadFrom("abc", null, System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA1)); } [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot, "The full .NET Framework supports more than one module per assembly")] - public static void Test_LoadModule_Netcore() + public void Test_LoadModule_Netcore() { Assembly assembly = typeof(AssemblyTests).Assembly; Assert.Throws(() => assembly.LoadModule("abc", null)); @@ -367,7 +361,7 @@ public static void Test_LoadModule_Netcore() [Fact] [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "The coreclr doesn't support more than one module per assembly")] - public static void Test_LoadModule_Netfx() + public void Test_LoadModule_Netfx() { Assembly assembly = typeof(AssemblyTests).Assembly; AssertExtensions.Throws(null, () => assembly.LoadModule("abc", null)); @@ -377,7 +371,7 @@ public static void Test_LoadModule_Netfx() #pragma warning disable 618 [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.LoadFromWithPartialName() not supported on UapAot")] - public static void Test_LoadWithPartialName() + public void Test_LoadWithPartialName() { string simplename = typeof(AssemblyTests).Assembly.GetName().Name; var assem = Assembly.LoadWithPartialName(simplename); @@ -389,8 +383,8 @@ public static void Test_LoadWithPartialName() [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.LoadFrom() not supported on UapAot")] public void LoadFrom_SamePath_ReturnsEqualAssemblies() { - Assembly assembly1 = Assembly.LoadFrom(destTestAssemblyPath); - Assembly assembly2 = Assembly.LoadFrom(destTestAssemblyPath); + Assembly assembly1 = Assembly.LoadFrom(DestTestAssemblyPath); + Assembly assembly2 = Assembly.LoadFrom(DestTestAssemblyPath); Assert.Equal(assembly1, assembly2); } @@ -401,7 +395,7 @@ public void LoadFrom_SameIdentityAsAssemblyWithDifferentPath_ReturnsEqualAssembl Assembly assembly1 = Assembly.LoadFrom(typeof(AssemblyTests).Assembly.Location); Assert.Equal(assembly1, typeof(AssemblyTests).Assembly); - Assembly assembly2 = Assembly.LoadFrom(loadFromTestPath); + Assembly assembly2 = Assembly.LoadFrom(LoadFromTestPath); if (PlatformDetection.IsFullFramework) { @@ -441,8 +435,8 @@ public void LoadFrom_NoSuchFile_ThrowsFileNotFoundException() [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.UnsafeLoadFrom() not supported on UapAot")] public void UnsafeLoadFrom_SamePath_ReturnsEqualAssemblies() { - Assembly assembly1 = Assembly.UnsafeLoadFrom(destTestAssemblyPath); - Assembly assembly2 = Assembly.UnsafeLoadFrom(destTestAssemblyPath); + Assembly assembly1 = Assembly.UnsafeLoadFrom(DestTestAssemblyPath); + Assembly assembly2 = Assembly.UnsafeLoadFrom(DestTestAssemblyPath); Assert.Equal(assembly1, assembly2); } @@ -450,7 +444,7 @@ public void UnsafeLoadFrom_SamePath_ReturnsEqualAssemblies() [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot, "The implementation of LoadFrom(string, byte[], AssemblyHashAlgorithm is not supported in .NET Core.")] public void LoadFrom_WithHashValue_NetCoreCore_ThrowsNotSupportedException() { - Assert.Throws(() => Assembly.LoadFrom(destTestAssemblyPath, new byte[0], Configuration.Assemblies.AssemblyHashAlgorithm.None)); + Assert.Throws(() => Assembly.LoadFrom(DestTestAssemblyPath, new byte[0], Configuration.Assemblies.AssemblyHashAlgorithm.None)); } [Fact] @@ -475,7 +469,7 @@ public void GetFiles() [Fact] [SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Assembly.CodeBase not supported on UapAot")] - public static void Load_AssemblyNameWithCodeBase() + public void Load_AssemblyNameWithCodeBase() { AssemblyName an = typeof(AssemblyTests).Assembly.GetName(); Assert.NotNull(an.CodeBase); @@ -491,7 +485,7 @@ private static Assembly GetGetCallingAssembly() private static Assembly LoadSystemCollectionsAssembly() { - // Force System.collections to be linked statically + // Force System.collections to be linkedally List li = new List(); li.Add(1); return Assembly.Load(new AssemblyName(typeof(List).GetTypeInfo().Assembly.FullName)); @@ -650,7 +644,7 @@ public void Test_SimpleAttribute() Assert.True(result, string.Format("Did not find custom attribute of type {0} ", attrType)); } - private static bool VerifyCustomAttribute(Type type, String attributeStr) + private bool VerifyCustomAttribute(Type type, String attributeStr) { Assembly asm = typeof(AssemblyCustomAttributeTest).Assembly; @@ -666,10 +660,10 @@ private static bool VerifyCustomAttribute(Type type, String attributeStr) } } - public static class AssemblyTests_GetTYpe + public class AssemblyTests_GetTYpe { [Fact] - public static void AssemblyGetTypeNoQualifierAllowed() + public void AssemblyGetTypeNoQualifierAllowed() { Assembly a = typeof(G).Assembly; string s = typeof(G).AssemblyQualifiedName; @@ -677,7 +671,7 @@ public static void AssemblyGetTypeNoQualifierAllowed() } [Fact] - public static void AssemblyGetTypeDoesntSearchMscorlib() + public void AssemblyGetTypeDoesntSearchMscorlib() { Assembly a = typeof(AssemblyTests_GetTYpe).Assembly; Assert.Throws(() => a.GetType("System.Object", throwOnError: true, ignoreCase: false)); @@ -685,7 +679,7 @@ public static void AssemblyGetTypeDoesntSearchMscorlib() } [Fact] - public static void AssemblyGetTypeDefaultsToItself() + public void AssemblyGetTypeDefaultsToItself() { Assembly a = typeof(AssemblyTests_GetTYpe).Assembly; Type t = a.GetType("G`1[[G`1[[System.Int32, mscorlib]]]]", throwOnError: true, ignoreCase: false); diff --git a/src/System.Runtime/tests/System/StringTests.cs b/src/System.Runtime/tests/System/StringTests.cs index 1e5858576453..0c66b0bd8c27 100644 --- a/src/System.Runtime/tests/System/StringTests.cs +++ b/src/System.Runtime/tests/System/StringTests.cs @@ -13,7 +13,7 @@ namespace System.Tests { - public partial class StringTests + public partial class StringTests : RemoteExecutorTestBase { private const string SoftHyphen = "\u00AD"; @@ -2233,29 +2233,27 @@ public static void ToLower(string s, string expected) Assert.Equal(expected, s.ToLower()); } - [Fact] - public static void ToLower_TurkishI() + private static IEnumerable ToLower_Culture_TestData() { - Helpers.PerformActionWithCulture(new CultureInfo("tr-TR"), () => - { - Assert.True("H\u0049 World".ToLower().Equals("h\u0131 world", StringComparison.Ordinal)); - Assert.True("H\u0130 World".ToLower().Equals("h\u0069 world", StringComparison.Ordinal)); - Assert.True("H\u0131 World".ToLower().Equals("h\u0131 world", StringComparison.Ordinal)); - }); + yield return new object[] { "H\u0049 World", "h\u0131 world", new CultureInfo("tr-TR") }; + yield return new object[] { "H\u0130 World", "h\u0069 world", new CultureInfo("tr-TR") }; + yield return new object[] { "H\u0131 World", "h\u0131 world", new CultureInfo("tr-TR") }; - Helpers.PerformActionWithCulture(new CultureInfo("en-US"), () => - { - Assert.True("H\u0049 World".ToLower().Equals("h\u0069 world", StringComparison.Ordinal)); - Assert.True("H\u0130 World".ToLower().Equals("h\u0069 world", StringComparison.Ordinal)); - Assert.True("H\u0131 World".ToLower().Equals("h\u0131 world", StringComparison.Ordinal)); - }); + yield return new object[] { "H\u0049 World", "h\u0069 world", new CultureInfo("en-US") }; + yield return new object[] { "H\u0130 World", "h\u0069 world", new CultureInfo("en-US") }; + yield return new object[] { "H\u0131 World", "h\u0131 world", new CultureInfo("en-US") }; - Helpers.PerformActionWithCulture(CultureInfo.InvariantCulture, () => - { - Assert.True("H\u0049 World".ToLower().Equals("h\u0069 world", StringComparison.Ordinal)); - Assert.True("H\u0130 World".ToLower().Equals("h\u0130 world", StringComparison.Ordinal)); - Assert.True("H\u0131 World".ToLower().Equals("h\u0131 world", StringComparison.Ordinal)); - }); + yield return new object[] { "H\u0049 World", "h\u0069 world", CultureInfo.InvariantCulture }; + yield return new object[] { "H\u0130 World", "h\u0130 world", CultureInfo.InvariantCulture }; + yield return new object[] { "H\u0131 World", "h\u0131 world", CultureInfo.InvariantCulture }; + } + + [Theory] + [MemberData(nameof(ToLower_Culture_TestData))] + public static void ToLower_Culture(string actual, string expected, CultureInfo culture) + { + Helpers.PerformActionWithCulture(culture, () => + Assert.True(actual.ToLower().Equals(expected, StringComparison.Ordinal))); } [Theory]