* 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.
[TearDown]
public void TearDown ()
{
+ _smtp = null;
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
}
if (listenSocket.AcceptAsync(asyncEventArgs))
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
+ mainEvent.Set();
} catch (Exception e) {
ex = e;
- } finally {
- mainEvent.Set();
}
});
Assert.IsTrue(readyEvent.WaitOne(1500));
clientSocket.NoDelay = true;
Assert.IsTrue(mainEvent.WaitOne(1500));
- Assert.AreEqual(serverSocket, acceptedSocket);
+ Assert.AreEqual(serverSocket, acceptedSocket, "x");
mainEvent.Reset();
if (acceptedSocket != null)
get { return _port ?? (_port = NetworkHelpers.FindFreePort ()).Value; }
}
+ [TearDown]
+ public void Teardown ()
+ {
+ _port = null;
+ }
+
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]