Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ee528ac

Browse files
AlexRadchstephentoub
authored andcommitted
Fixed netfx System.Text.Encoding.Tests fails on non-English Windows (#28349)
1 parent d9fa123 commit ee528ac

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/System.Text.Encoding/tests/Encoding/EncodingGetEncodingTests.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Diagnostics;
56
using System.Globalization;
67
using Xunit;
78

89
namespace System.Text.Tests
910
{
10-
public class EncodingGetEncodingTest
11+
public class EncodingGetEncodingTest : RemoteExecutorTestBase
1112
{
1213
[Fact]
1314
public void GetEncoding_String_Invalid()
@@ -99,10 +100,10 @@ public void TestEncodingNameAndCopdepageNumber()
99100
[Fact]
100101
public void GetEncoding_EncodingName()
101102
{
102-
CultureInfo originalUICulture = CultureInfo.CurrentUICulture;
103-
try
103+
// Workaround issue: UWP culture is process wide
104+
RemoteInvoke(() =>
104105
{
105-
CultureInfo.CurrentCulture = new CultureInfo("en-US");
106+
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
106107

107108
foreach (var map in s_mapping)
108109
{
@@ -115,11 +116,7 @@ public void GetEncoding_EncodingName()
115116

116117
Assert.All(name, ch => Assert.InRange(ch, 0, 127));
117118
}
118-
}
119-
finally
120-
{
121-
CultureInfo.CurrentUICulture = originalUICulture;
122-
}
119+
}).Dispose();
123120
}
124121

125122
[Fact]

src/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,11 @@
8181
<Compile Include="Decoder\Decoder.cs" />
8282
<Compile Include="Encoder\Encoder.cs" />
8383
</ItemGroup>
84+
<ItemGroup>
85+
<ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
86+
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
87+
<Name>RemoteExecutorConsoleApp</Name>
88+
</ProjectReference>
89+
</ItemGroup>
8490
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
8591
</Project>

0 commit comments

Comments
 (0)