Consolidate .netcoreapp.cs files because System.Diagnostics.* projects is no longer...
authorRoman Marusyk <Marusyk@users.noreply.github.com>
Sun, 22 Dec 2019 06:13:14 +0000 (08:13 +0200)
committerJan Kotas <jkotas@microsoft.com>
Sun, 22 Dec 2019 06:13:14 +0000 (22:13 -0800)
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs [deleted file]
src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs
src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs [deleted file]
src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj
src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.cs
src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs [deleted file]
src/libraries/System.Diagnostics.TraceSource/tests/System.Diagnostics.TraceSource.Tests.csproj

index 0621fa0..e91bc99 100644 (file)
@@ -20,7 +20,7 @@ using Xunit;
 
 namespace System.Diagnostics.Tests
 {
-    public partial class ProcessStartInfoTests : ProcessTestBase
+    public class ProcessStartInfoTests : ProcessTestBase
     {
         [Fact]
         public void TestEnvironmentProperty()
@@ -1117,5 +1117,65 @@ namespace System.Diagnostics.Tests
 
             Assert.Equal(expected, Assert.Throws<Win32Exception>(() => Process.Start(info)).NativeErrorCode);
         }
+
+        [Fact]
+        public void UnintializedArgumentList()
+        {
+            ProcessStartInfo psi = new ProcessStartInfo();
+            Assert.Equal(0, psi.ArgumentList.Count);
+
+            psi = new ProcessStartInfo("filename", "-arg1 -arg2");
+            Assert.Equal(0, psi.ArgumentList.Count);
+        }
+
+        [Fact]
+        public void InitializeWithArgumentList()
+        {
+            ProcessStartInfo psi = new ProcessStartInfo("filename");
+            psi.ArgumentList.Add("arg1");
+            psi.ArgumentList.Add("arg2");
+
+            Assert.Equal(2, psi.ArgumentList.Count);
+            Assert.Equal("arg1", psi.ArgumentList[0]);
+            Assert.Equal("arg2", psi.ArgumentList[1]);
+        }
+
+        [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // No Notepad on Nano
+        [MemberData(nameof(UseShellExecute))]
+        [OuterLoop("Launches notepad")]
+        [PlatformSpecific(TestPlatforms.Windows)]
+        public void StartInfo_NotepadWithContent_withArgumentList(bool useShellExecute)
+        {
+            string tempFile = GetTestFilePath() + ".txt";
+            File.WriteAllText(tempFile, $"StartInfo_NotepadWithContent({useShellExecute})");
+
+            ProcessStartInfo info = new ProcessStartInfo
+            {
+                UseShellExecute = useShellExecute,
+                FileName = @"notepad.exe",
+                Arguments = null,
+                WindowStyle = ProcessWindowStyle.Minimized
+            };
+
+            info.ArgumentList.Add(tempFile);
+
+            using (var process = Process.Start(info))
+            {
+                Assert.True(process != null, $"Could not start {info.FileName} {info.Arguments} UseShellExecute={info.UseShellExecute}");
+
+                try
+                {
+                    process.WaitForInputIdle(); // Give the file a chance to load
+                    Assert.Equal("notepad", process.ProcessName);
+
+                    // On some Windows versions, the file extension is not included in the title
+                    Assert.StartsWith(Path.GetFileNameWithoutExtension(tempFile), process.MainWindowTitle);
+                }
+                finally
+                {
+                    process?.Kill();
+                }
+            }
+        }
     }
 }
diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.netcoreapp.cs
deleted file mode 100644 (file)
index 29214a3..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.IO;
-using Xunit;
-
-namespace System.Diagnostics.Tests
-{
-    public partial class ProcessStartInfoTests
-    {
-        [Fact]
-        public void UnintializedArgumentList()
-        {
-            ProcessStartInfo psi = new ProcessStartInfo();
-            Assert.Equal(0, psi.ArgumentList.Count);
-
-            psi = new ProcessStartInfo("filename", "-arg1 -arg2");
-            Assert.Equal(0, psi.ArgumentList.Count);
-        }
-
-        [Fact]
-        public void InitializeWithArgumentList()
-        {
-            ProcessStartInfo psi = new ProcessStartInfo("filename");
-            psi.ArgumentList.Add("arg1");
-            psi.ArgumentList.Add("arg2");
-
-            Assert.Equal(2, psi.ArgumentList.Count);
-            Assert.Equal("arg1", psi.ArgumentList[0]);
-            Assert.Equal("arg2", psi.ArgumentList[1]);
-        }
-
-        [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))] // No Notepad on Nano
-        [MemberData(nameof(UseShellExecute))]
-        [OuterLoop("Launches notepad")]
-        [PlatformSpecific(TestPlatforms.Windows)]
-        public void StartInfo_NotepadWithContent_withArgumentList(bool useShellExecute)
-        {
-            string tempFile = GetTestFilePath() + ".txt";
-            File.WriteAllText(tempFile, $"StartInfo_NotepadWithContent({useShellExecute})");
-
-            ProcessStartInfo info = new ProcessStartInfo
-            {
-                UseShellExecute = useShellExecute,
-                FileName = @"notepad.exe",
-                Arguments = null,
-                WindowStyle = ProcessWindowStyle.Minimized
-            };
-
-            info.ArgumentList.Add(tempFile);
-
-            using (var process = Process.Start(info))
-            {
-                Assert.True(process != null, $"Could not start {info.FileName} {info.Arguments} UseShellExecute={info.UseShellExecute}");
-
-                try
-                {
-                    process.WaitForInputIdle(); // Give the file a chance to load
-                    Assert.Equal("notepad", process.ProcessName);
-
-                    // On some Windows versions, the file extension is not included in the title
-                    Assert.StartsWith(Path.GetFileNameWithoutExtension(tempFile), process.MainWindowTitle);
-                }
-                finally
-                {
-                    process?.Kill();
-                }
-            }
-        }
-    }
-}
index 29a959c..9be34d8 100644 (file)
@@ -1,6 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
+using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.IO;
@@ -14,7 +15,7 @@ using Xunit;
 
 namespace System.Diagnostics.Tests
 {
-    public partial class ProcessStreamReadTests : ProcessTestBase
+    public class ProcessStreamReadTests : ProcessTestBase
     {
         [Fact]
         public void TestSyncErrorStream()
@@ -544,5 +545,48 @@ namespace System.Diagnostics.Tests
                 Assert.True(p.WaitForExit(WaitInMS));
             }
         }
+
+        [Fact]
+        public void TestCustomStandardInputEncoding()
+        {
+            var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName);
+            process.StartInfo.RedirectStandardInput = true;
+            process.StartInfo.StandardInputEncoding = Encoding.UTF32;
+            process.StartInfo.RedirectStandardOutput = true;
+            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
+            process.Start();
+
+            const string TestLine = "\U0001f627\U0001f62e\U0001f62f";
+            process.StandardInput.WriteLine(TestLine);
+            process.StandardInput.Close();
+
+            var output = process.StandardOutput.ReadLine();
+            Assert.Equal(TestLine, output);
+
+            Assert.True(process.WaitForExit(WaitInMS));
+            Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode);
+        }
+
+        [Fact]
+        public void TestMismatchedStandardInputEncoding()
+        {
+            var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName);
+            process.StartInfo.RedirectStandardInput = true;
+            // incorrect: the process will be writing in UTF-32
+            process.StartInfo.StandardInputEncoding = Encoding.ASCII;
+            process.StartInfo.RedirectStandardOutput = true;
+            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
+            process.Start();
+
+            const string TestLine = "\U0001f627\U0001f62e\U0001f62f";
+            process.StandardInput.WriteLine(TestLine);
+            process.StandardInput.Close();
+
+            var output = process.StandardOutput.ReadLine();
+            Assert.NotEqual(TestLine, output);
+
+            Assert.True(process.WaitForExit(WaitInMS));
+            Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode);
+        }
     }
 }
diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.netcoreapp.cs
deleted file mode 100644 (file)
index 5be8043..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
-
-namespace System.Diagnostics.Tests
-{
-    public partial class ProcessStreamReadTests : ProcessTestBase
-    {
-        [Fact]
-        public void TestCustomStandardInputEncoding()
-        {
-            var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName);
-            process.StartInfo.RedirectStandardInput = true;
-            process.StartInfo.StandardInputEncoding = Encoding.UTF32;
-            process.StartInfo.RedirectStandardOutput = true;
-            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
-            process.Start();
-
-            const string TestLine = "\U0001f627\U0001f62e\U0001f62f";
-            process.StandardInput.WriteLine(TestLine);
-            process.StandardInput.Close();
-
-            var output = process.StandardOutput.ReadLine();
-            Assert.Equal(TestLine, output);
-
-            Assert.True(process.WaitForExit(WaitInMS));
-            Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode);
-        }
-
-        [Fact]
-        public void TestMismatchedStandardInputEncoding()
-        {
-            var process = CreateProcessPortable(RemotelyInvokable.ReadLineWithCustomEncodingWriteLineWithUtf8, Encoding.UTF32.WebName);
-            process.StartInfo.RedirectStandardInput = true;
-            // incorrect: the process will be writing in UTF-32
-            process.StartInfo.StandardInputEncoding = Encoding.ASCII;
-            process.StartInfo.RedirectStandardOutput = true;
-            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
-            process.Start();
-
-            const string TestLine = "\U0001f627\U0001f62e\U0001f62f";
-            process.StandardInput.WriteLine(TestLine);
-            process.StandardInput.Close();
-
-            var output = process.StandardOutput.ReadLine();
-            Assert.NotEqual(TestLine, output);
-
-            Assert.True(process.WaitForExit(WaitInMS));
-            Assert.Equal(RemotelyInvokable.SuccessExitCode, process.ExitCode);
-        }
-    }
-}
index bcae59c..162b60a 100644 (file)
@@ -33,8 +33,6 @@
     <Compile Include="ProcessWaitingTests.cs" />
     <Compile Include="RemotelyInvokable.cs" />
     <Compile Include="XunitAssemblyAttributes.cs" />
-    <Compile Include="ProcessStartInfoTests.netcoreapp.cs" />
-    <Compile Include="ProcessStreamReadTests.netcoreapp.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetsWindows)' == 'true'">
     <Compile Include="ProcessTests.Windows.cs" />
index a0b0cfd..8c8be77 100644 (file)
@@ -4,11 +4,14 @@
 
 using System.IO;
 using System.Reflection;
+using System.Reflection.Emit;
+using System.Linq;
+using Microsoft.DotNet.RemoteExecutor;
 using Xunit;
 
 namespace System.Diagnostics.TraceSourceTests
 {
-    public partial class DefaultTraceListenerClassTests : FileCleanupTestBase
+    public class DefaultTraceListenerClassTests : FileCleanupTestBase
     {
         private class TestDefaultTraceListener : DefaultTraceListener
         {
@@ -139,5 +142,43 @@ namespace System.Diagnostics.TraceSourceTests
             listener.LogFileName = expectedLogFileName;
             Assert.Equal(expectedLogFileName, listener.LogFileName);
         }
+
+        [Fact]
+        public void EntryAssemblyName_Default_IncludedInTrace()
+        {
+            RemoteExecutor.Invoke(() =>
+            {
+                var listener = new TestDefaultTraceListener();
+                Trace.Listeners.Add(listener);
+                Trace.TraceError("hello world");
+                Assert.Equal(Assembly.GetEntryAssembly()?.GetName().Name + " Error: 0 : hello world", listener.Output.Trim());
+            }).Dispose();
+        }
+
+        [Fact]
+        public void EntryAssemblyName_Null_NotIncludedInTrace()
+        {
+            RemoteExecutor.Invoke(() =>
+            {
+                MakeAssemblyGetEntryAssemblyReturnNull();
+
+                var listener = new TestDefaultTraceListener();
+                Trace.Listeners.Add(listener);
+                Trace.TraceError("hello world");
+                Assert.Equal("Error: 0 : hello world", listener.Output.Trim());
+            }).Dispose();
+        }
+
+        /// <summary>
+        /// Makes Assembly.GetEntryAssembly() return null using private reflection.
+        /// </summary>
+        private static void MakeAssemblyGetEntryAssemblyReturnNull()
+        {
+            typeof(Assembly)
+                .GetField("s_forceNullEntryPoint", BindingFlags.NonPublic | BindingFlags.Static)
+                .SetValue(null, true);
+
+            Assert.Null(Assembly.GetEntryAssembly());
+        }
     }
 }
diff --git a/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs b/src/libraries/System.Diagnostics.TraceSource/tests/DefaultTraceListenerClassTests.netcoreapp.cs
deleted file mode 100644 (file)
index 0dacf4e..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.IO;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Linq;
-using Microsoft.DotNet.RemoteExecutor;
-using Xunit;
-
-namespace System.Diagnostics.TraceSourceTests
-{
-    public partial class DefaultTraceListenerClassTests
-    {
-        [Fact]
-        public void EntryAssemblyName_Default_IncludedInTrace()
-        {
-            RemoteExecutor.Invoke(() =>
-            {
-                var listener = new TestDefaultTraceListener();
-                Trace.Listeners.Add(listener);
-                Trace.TraceError("hello world");
-                Assert.Equal(Assembly.GetEntryAssembly()?.GetName().Name + " Error: 0 : hello world", listener.Output.Trim());
-            }).Dispose();
-        }
-
-        [Fact]
-        public void EntryAssemblyName_Null_NotIncludedInTrace()
-        {
-            RemoteExecutor.Invoke(() =>
-            {
-                MakeAssemblyGetEntryAssemblyReturnNull();
-
-                var listener = new TestDefaultTraceListener();
-                Trace.Listeners.Add(listener);
-                Trace.TraceError("hello world");
-                Assert.Equal("Error: 0 : hello world", listener.Output.Trim());
-            }).Dispose();
-        }
-
-        /// <summary>
-        /// Makes Assembly.GetEntryAssembly() return null using private reflection.
-        /// </summary>
-        private static void MakeAssemblyGetEntryAssemblyReturnNull()
-        {
-            typeof(Assembly)
-                .GetField("s_forceNullEntryPoint", BindingFlags.NonPublic | BindingFlags.Static)
-                .SetValue(null, true);
-
-            Assert.Null(Assembly.GetEntryAssembly());
-        }
-    }
-}
index eaceb29..63d79be 100644 (file)
@@ -24,7 +24,4 @@
     <Compile Include="TraceTestHelper.cs" />
     <Compile Include="CorrelationManagerTests.cs" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetCoreApp)' == 'true'">
-    <Compile Include="DefaultTraceListenerClassTests.netcoreapp.cs" />
-  </ItemGroup>
 </Project>
\ No newline at end of file