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

Commit c7f2e35

Browse files
authored
Fix StringWriterTests (#26510)
1 parent c955510 commit c7f2e35

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/System.IO/tests/StringWriter/StringWriterTests.cs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
using Xunit;
66
using System;
7+
using System.Diagnostics;
78
using System.Globalization;
89
using System.IO;
910
using System.Text;
1011
using System.Threading.Tasks;
1112

1213
namespace System.IO.Tests
1314
{
14-
public partial class StringWriterTests
15+
public partial class StringWriterTests : RemoteExecutorTestBase
1516
{
1617
static int[] iArrInvalidValues = new int[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, int.MinValue, short.MinValue };
1718
static int[] iArrLargeValues = new int[] { int.MaxValue, int.MaxValue - 1, int.MaxValue / 2, int.MaxValue / 10, int.MaxValue / 100 };
@@ -291,10 +292,9 @@ public static void GetEncoding()
291292
[Fact]
292293
public static void TestWriteMisc()
293294
{
294-
CultureInfo old = CultureInfo.CurrentCulture;
295-
CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
296-
try
295+
RemoteInvoke(() =>
297296
{
297+
CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
298298
var sw = new StringWriter();
299299

300300
sw.Write(true);
@@ -308,11 +308,7 @@ public static void TestWriteMisc()
308308
sw.Write((ulong)ulong.MaxValue);
309309

310310
Assert.Equal("Truea1234.013452342.0123456-92233720368547758081234.5429496729518446744073709551615", sw.ToString());
311-
}
312-
finally
313-
{
314-
CultureInfo.CurrentCulture = old;
315-
}
311+
});
316312
}
317313

318314
[Fact]
@@ -326,10 +322,9 @@ public static void TestWriteObject()
326322
[Fact]
327323
public static void TestWriteLineMisc()
328324
{
329-
CultureInfo old = CultureInfo.CurrentCulture;
330-
CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
331-
try
325+
RemoteInvoke(() =>
332326
{
327+
CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
333328
var sw = new StringWriter();
334329
sw.WriteLine((bool)false);
335330
sw.WriteLine((char)'B');
@@ -342,11 +337,7 @@ public static void TestWriteLineMisc()
342337
Assert.Equal(
343338
string.Format("False{0}B{0}987{0}875634{0}1.23457{0}45634563{0}18446744073709551615{0}", Environment.NewLine),
344339
sw.ToString());
345-
}
346-
finally
347-
{
348-
CultureInfo.CurrentCulture = old;
349-
}
340+
});
350341
}
351342

352343
[Fact]

src/System.IO/tests/System.IO.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
<Compile Include="TextWriter\TextWriterTests.cs" />
7878
<Compile Include="TextWriter\TextWriterTests.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp'" />
7979
</ItemGroup>
80+
<ItemGroup>
81+
<ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
82+
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
83+
<Name>RemoteExecutorConsoleApp</Name>
84+
</ProjectReference>
85+
</ItemGroup>
8086
<ItemGroup>
8187
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
8288
</ItemGroup>

0 commit comments

Comments
 (0)