From: Rolf Bjarne Kvinge Date: Thu, 29 Sep 2016 10:01:49 +0000 (+0200) Subject: [System] Fix tests that regressed in e6536dd. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=ad6f78afec8fcb01a38e83ba7f4a4ec515b1f808 [System] Fix tests that regressed in e6536dd. * I got confused between [TestFixtureSetup] and [Setup], so fix tests whose [Setup] methods were changed/removed to properly clean up after each test (using a [TearDown] method) so that the next time the on-demand creation of objects works as expected (i.e. objects created in the [Setup] method should be created on-demand once for each method instead of once for each class). * Also fix SocketAcceptAsyncTest, the change to properly catch exceptions on background threads was incorrect. --- diff --git a/mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs b/mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs index 8c163f77b02..d3a39e41315 100644 --- a/mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs +++ b/mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs @@ -34,6 +34,7 @@ namespace MonoTests.System.Net.Mail [TearDown] public void TearDown () { + _smtp = null; if (Directory.Exists (tempFolder)) Directory.Delete (tempFolder, true); } diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs index d09341b9710..fff160c768c 100644 --- a/mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs @@ -48,10 +48,9 @@ namespace MonoTests.System.Net.Sockets if (listenSocket.AcceptAsync(asyncEventArgs)) return; acceptedSocket = asyncEventArgs.AcceptSocket; + mainEvent.Set(); } catch (Exception e) { ex = e; - } finally { - mainEvent.Set(); } }); Assert.IsTrue(readyEvent.WaitOne(1500)); @@ -64,7 +63,7 @@ namespace MonoTests.System.Net.Sockets clientSocket.NoDelay = true; Assert.IsTrue(mainEvent.WaitOne(1500)); - Assert.AreEqual(serverSocket, acceptedSocket); + Assert.AreEqual(serverSocket, acceptedSocket, "x"); mainEvent.Reset(); if (acceptedSocket != null) diff --git a/mcs/class/System/Test/System.Net/HttpListenerTest.cs b/mcs/class/System/Test/System.Net/HttpListenerTest.cs index bbd716c0ed2..09d3cb0f3f2 100644 --- a/mcs/class/System/Test/System.Net/HttpListenerTest.cs +++ b/mcs/class/System/Test/System.Net/HttpListenerTest.cs @@ -44,6 +44,12 @@ namespace MonoTests.System.Net { get { return _port ?? (_port = NetworkHelpers.FindFreePort ()).Value; } } + [TearDown] + public void Teardown () + { + _port = null; + } + [Test] #if FEATURE_NO_BSD_SOCKETS [ExpectedException (typeof (PlatformNotSupportedException))]