Fix StringWriterTests (dotnet/corefx#26510)
authorDan Moseley <danmose@microsoft.com>
Mon, 22 Jan 2018 21:43:13 +0000 (13:43 -0800)
committerGitHub <noreply@github.com>
Mon, 22 Jan 2018 21:43:13 +0000 (13:43 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/c7f2e354d9dc1e7155c99b07009f46c52cafcea7

src/libraries/System.IO/tests/StringWriter/StringWriterTests.cs
src/libraries/System.IO/tests/System.IO.Tests.csproj

index 4155c9d..fa1fb7a 100644 (file)
@@ -4,6 +4,7 @@
 
 using Xunit;
 using System;
+using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 using System.Text;
@@ -11,7 +12,7 @@ using System.Threading.Tasks;
 
 namespace System.IO.Tests
 {
-    public partial class StringWriterTests
+    public partial class StringWriterTests : RemoteExecutorTestBase
     {
         static int[] iArrInvalidValues = new int[] { -1, -2, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000, int.MinValue, short.MinValue };
         static int[] iArrLargeValues = new int[] { int.MaxValue, int.MaxValue - 1, int.MaxValue / 2, int.MaxValue / 10, int.MaxValue / 100 };
@@ -291,10 +292,9 @@ namespace System.IO.Tests
         [Fact]
         public static void TestWriteMisc()
         {
-            CultureInfo old = CultureInfo.CurrentCulture;
-            CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
-            try
+            RemoteInvoke(() => 
             {
+                CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
                 var sw = new StringWriter();
 
                 sw.Write(true);
@@ -308,11 +308,7 @@ namespace System.IO.Tests
                 sw.Write((ulong)ulong.MaxValue);
 
                 Assert.Equal("Truea1234.013452342.0123456-92233720368547758081234.5429496729518446744073709551615", sw.ToString());
-            }
-            finally
-            {
-                CultureInfo.CurrentCulture = old;
-            }
+            });
         }
 
         [Fact]
@@ -326,10 +322,9 @@ namespace System.IO.Tests
         [Fact]
         public static void TestWriteLineMisc()
         {
-            CultureInfo old = CultureInfo.CurrentCulture;
-            CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
-            try
+            RemoteInvoke(() =>
             {
+                CultureInfo.CurrentCulture = new CultureInfo("en-US"); // floating-point formatting comparison depends on culture
                 var sw = new StringWriter();
                 sw.WriteLine((bool)false);
                 sw.WriteLine((char)'B');
@@ -342,11 +337,7 @@ namespace System.IO.Tests
                 Assert.Equal(
                     string.Format("False{0}B{0}987{0}875634{0}1.23457{0}45634563{0}18446744073709551615{0}", Environment.NewLine),
                     sw.ToString());
-            }
-            finally
-            {
-                CultureInfo.CurrentCulture = old;
-            }
+            });
         }
 
         [Fact]
index 7a2412d..52cf082 100644 (file)
     <Compile Include="TextWriter\TextWriterTests.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp'" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
+      <Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
+      <Name>RemoteExecutorConsoleApp</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
     <EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />