Author: gert
Date: 2007-01-02 10:07:35 -0500 (Tue, 02 Jan 2007)
New Revision: 70366
Added:
trunk/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
Modified:
trunk/mcs/class/System/ChangeLog
trunk/mcs/class/System/System.Diagnostics/ChangeLog
trunk/mcs/class/System/System.Diagnostics/Process.cs
trunk/mcs/class/System/System_test.dll.sources
trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
Log:
* ProcessTest.cs: Added null check tests.
* Process.cs: Allow GetProcesses and GetProcessById overloads with
machine name to work for local machine.
* System_test.dll.sources: Added ProcessTest.cs.
Modified: trunk/mcs/class/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/ChangeLog 2007-01-02 14:48:40 UTC (rev 70365)
+++ trunk/mcs/class/System/ChangeLog 2007-01-02 15:07:35 UTC (rev 70366)
@@ -1,3 +1,7 @@
+2007-01-02 Gert Driesen <[EMAIL PROTECTED]>
+
+ * System_test.dll.sources: Added ProcessTest.cs.
+
2006-12-22 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* System_test.dll.sources: added DefaultBindingPropertyAttributeTest.cs
Modified: trunk/mcs/class/System/System.Diagnostics/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/ChangeLog 2007-01-02 14:48:40 UTC
(rev 70365)
+++ trunk/mcs/class/System/System.Diagnostics/ChangeLog 2007-01-02 15:07:35 UTC
(rev 70366)
@@ -1,3 +1,8 @@
+2007-01-02 Gert Driesen <[EMAIL PROTECTED]>
+
+ * Process.cs: Allow GetProcesses and GetProcessById overloads with
+ machine name to work for local machine.
+
2006-12-29 Robert Jordan <[EMAIL PROTECTED]>
* TraceImpl.cs (Assert): Include line numbers in the stack trace
Modified: trunk/mcs/class/System/System.Diagnostics/Process.cs
===================================================================
--- trunk/mcs/class/System/System.Diagnostics/Process.cs 2007-01-02
14:48:40 UTC (rev 70365)
+++ trunk/mcs/class/System/System.Diagnostics/Process.cs 2007-01-02
15:07:35 UTC (rev 70366)
@@ -776,9 +776,15 @@
return (new Process (proc, processId));
}
- [MonoTODO]
+ [MonoTODO ("There is no support for retrieving process
information from a remote machine")]
public static Process GetProcessById(int processId, string
machineName) {
- throw new NotImplementedException();
+ if (machineName == null)
+ throw new ArgumentNullException ("machineName");
+
+ if (!IsLocalMachine (machineName))
+ throw new NotImplementedException ();
+
+ return GetProcessById (processId);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -806,7 +812,13 @@
[MonoTODO ("There is no support for retrieving process
information from a remote machine")]
public static Process[] GetProcesses(string machineName) {
- throw new NotImplementedException();
+ if (machineName == null)
+ throw new ArgumentNullException ("machineName");
+
+ if (!IsLocalMachine (machineName))
+ throw new NotImplementedException ();
+
+ return GetProcesses ();
}
public static Process[] GetProcessesByName(string processName)
@@ -1126,7 +1138,14 @@
return(false);
}
+ private static bool IsLocalMachine (string machineName)
+ {
+ if (machineName == "." || machineName.Length == 0)
+ return true;
+ return (string.Compare (machineName,
Environment.MachineName, true) == 0);
+ }
+
#if NET_2_0
public event DataReceivedEventHandler OutputDataReceived;
public event DataReceivedEventHandler ErrorDataReceived;
Modified: trunk/mcs/class/System/System_test.dll.sources
===================================================================
--- trunk/mcs/class/System/System_test.dll.sources 2007-01-02 14:48:40 UTC
(rev 70365)
+++ trunk/mcs/class/System/System_test.dll.sources 2007-01-02 15:07:35 UTC
(rev 70366)
@@ -151,6 +151,7 @@
System.Diagnostics/EventSourceCreationDataTest.cs
System.Diagnostics/PerformanceCounterPermissionAttributeTest.cs
System.Diagnostics/PerformanceCounterPermissionTest.cs
+System.Diagnostics/ProcessTest.cs
System.IO/FileSystemWatcherTest.cs
System.IO.Compression/DeflateStreamTest.cs
System.IO.Compression/GzipStreamTest.cs
Modified: trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog 2007-01-02
14:48:40 UTC (rev 70365)
+++ trunk/mcs/class/System/Test/System.Diagnostics/ChangeLog 2007-01-02
15:07:35 UTC (rev 70366)
@@ -1,3 +1,7 @@
+2007-01-02 Gert Driesen <[EMAIL PROTECTED]>
+
+ * ProcessTest.cs: Added null check tests.
+
2006-08-27 Gert Driesen <[EMAIL PROTECTED]>
* EventLogTest.cs: Added tests for log name validation in
Added: trunk/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
2007-01-02 14:48:40 UTC (rev 70365)
+++ trunk/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
2007-01-02 15:07:35 UTC (rev 70366)
@@ -0,0 +1,50 @@
+//
+// ProcessTest.cs - NUnit Test Cases for System.Diagnostics.Process
+//
+// Authors:
+// Gert Driesen ([EMAIL PROTECTED])
+//
+// (C) 2007 Gert Driesen
+//
+
+using System;
+using System.Diagnostics;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Diagnostics
+{
+ [TestFixture]
+ public class ProcessTest
+ {
+ [Test]
+ public void GetProcessById_MachineName_Null ()
+ {
+ try {
+ Process.GetProcessById (1, (string) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.Message, "#3");
+ Assert.IsNotNull (ex.ParamName, "#4");
+ Assert.AreEqual ("machineName", ex.ParamName,
"#5");
+ Assert.IsNull (ex.InnerException, "#6");
+ }
+ }
+
+ [Test]
+ public void GetProcesses_MachineName_Null ()
+ {
+ try {
+ Process.GetProcesses ((string) null);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.Message, "#3");
+ Assert.IsNotNull (ex.ParamName, "#4");
+ Assert.AreEqual ("machineName", ex.ParamName,
"#5");
+ Assert.IsNull (ex.InnerException, "#6");
+ }
+ }
+ }
+}
Property changes on:
trunk/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches