Merge pull request #2274 from esdrubal/udpclientreceive
[mono.git] / mcs / class / System / Test / System.Diagnostics / ProcessTest.cs
index d4372a1ddddc76083a6022ab54d46aa4212ec533..602a07d017a487e811174e4909f508256dcba424 100644 (file)
@@ -104,6 +104,7 @@ namespace MonoTests.System.Diagnostics
                        }
                }
 
+#if MONO_FEATURE_PROCESS_START
                [Test] // Start ()
                public void Start1_FileName_Empty ()
                {
@@ -835,13 +836,38 @@ namespace MonoTests.System.Diagnostics
                        p.BeginOutputReadLine ();
                        p.WaitForExit ();
 
-                       exited.Wait (10000);
+                       Assert.IsTrue (exited.Wait (10000));
                        Assert.AreEqual (1, exitedCalledCounter);
                        Thread.Sleep (50);
                        Assert.AreEqual (1, exitedCalledCounter);
                }
 
-               
+               [Test]
+               [NUnit.Framework.Category ("MobileNotWorking")]
+               public void TestDisableEventsBeforeExitedEvent ()
+               {
+                       Process p = new Process ();
+                       
+                       p.StartInfo = GetCrossPlatformStartInfo ();
+                       p.StartInfo.UseShellExecute = false;
+                       p.StartInfo.RedirectStandardOutput = true;
+                       p.StartInfo.RedirectStandardError = true;
+
+                       p.EnableRaisingEvents = false;
+
+                       var exitedCalledCounter = 0;
+                       p.Exited += (object sender, EventArgs e) => {
+                               exitedCalledCounter++;
+                       };
+
+                       p.Start ();
+                       p.BeginErrorReadLine ();
+                       p.BeginOutputReadLine ();
+                       p.WaitForExit ();
+
+                       Assert.AreEqual (0, exitedCalledCounter);
+               }
+
                ProcessStartInfo GetCrossPlatformStartInfo ()
                {
                        if (RunningOnUnix) {
@@ -855,6 +881,7 @@ namespace MonoTests.System.Diagnostics
                        } else
                                return new ProcessStartInfo ("help", "");
                }
+#endif // MONO_FEATURE_PROCESS_START
 
                [Test]
                public void ProcessName_NotStarted ()
@@ -876,6 +903,7 @@ namespace MonoTests.System.Diagnostics
                        Assert.IsNull (e.InnerException, "IOE inner exception should be null");
                }
                
+#if MONO_FEATURE_PROCESS_START
                [Test]
                [NUnit.Framework.Category ("MobileNotWorking")]
                public void ProcessName_AfterExit ()
@@ -906,6 +934,7 @@ namespace MonoTests.System.Diagnostics
                        
                        Assert.IsNull (e.InnerException, "IOE inner exception should be null");
                }
+#endif // MONO_FEATURE_PROCESS_START
 
                [Test]
                public void Handle_ThrowsOnNotStarted ()
@@ -923,6 +952,7 @@ namespace MonoTests.System.Diagnostics
                        Assert.IsFalse (Process.GetCurrentProcess ().HasExited);
                }
 
+#if MONO_FEATURE_PROCESS_START
                [Test]
                [NUnit.Framework.Category ("MobileNotWorking")]
                public void DisposeWithDisposedStreams ()
@@ -952,6 +982,7 @@ namespace MonoTests.System.Diagnostics
                                        p.StandardInput.Write ('x');
                        }
                }
+#endif // MONO_FEATURE_PROCESS_START
 
                [Test]
                public void Modules () {