private void DisconnectAsyncConnectRunning(bool logout) { using (var server = new ImapPseudoServer()) { server.Start(); using (var client = new ImapClient(server.Host, server.Port, "user")) { client.BeginConnect("pass"); try { if (logout) client.Logout(); else client.Disconnect(); Assert.Fail("InvalidOperationException not thrown"); } catch (InvalidOperationException) { } } } }