diff --git a/MailKit/Net/Imap/ImapClient.cs b/MailKit/Net/Imap/ImapClient.cs index 69ebc19177..ae9ff3f8c9 100644 --- a/MailKit/Net/Imap/ImapClient.cs +++ b/MailKit/Net/Imap/ImapClient.cs @@ -124,7 +124,6 @@ public ImapClient (IProtocolLogger protocolLogger) : base (protocolLogger) // Note: This is only needed for UnitTests. internal char TagPrefix { - get { return engine.TagPrefix; } set { engine.TagPrefix = value; } } @@ -1346,60 +1345,6 @@ public override void Authenticate (Encoding encoding, ICredentials credentials, OnAuthenticated (ic.ResponseText ?? string.Empty, cancellationToken); } - internal void ReplayConnect (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - CheckDisposed (); - - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - engine.Uri = new Uri ($"imap://{host}:143"); - engine.Connect (new ImapStream (replayStream, ProtocolLogger), cancellationToken); - engine.TagPrefix = 'A'; - secure = false; - - if (engine.CapabilitiesVersion == 0) - engine.QueryCapabilities (cancellationToken); - - // Note: we capture the state here in case someone calls Authenticate() from within the Connected event handler. - var authenticated = engine.State == ImapEngineState.Authenticated; - - OnConnected (host, 143, SecureSocketOptions.None); - - if (authenticated) - OnAuthenticated (string.Empty, cancellationToken); - } - - internal async Task ReplayConnectAsync (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - CheckDisposed (); - - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - engine.Uri = new Uri ($"imap://{host}:143"); - await engine.ConnectAsync (new ImapStream (replayStream, ProtocolLogger), cancellationToken).ConfigureAwait (false); - engine.TagPrefix = 'A'; - secure = false; - - if (engine.CapabilitiesVersion == 0) - await engine.QueryCapabilitiesAsync (cancellationToken).ConfigureAwait (false); - - // Note: we capture the state here in case someone calls Authenticate() from within the Connected event handler. - var authenticated = engine.State == ImapEngineState.Authenticated; - - OnConnected (host, 143, SecureSocketOptions.None); - - if (authenticated) - await OnAuthenticatedAsync (string.Empty, cancellationToken).ConfigureAwait (false); - } - internal static void ComputeDefaultValues (string host, ref int port, ref SecureSocketOptions options, out Uri uri, out bool starttls) { switch (options) { diff --git a/MailKit/Net/Pop3/Pop3Client.cs b/MailKit/Net/Pop3/Pop3Client.cs index cc0fee9cf0..442bbafdd4 100644 --- a/MailKit/Net/Pop3/Pop3Client.cs +++ b/MailKit/Net/Pop3/Pop3Client.cs @@ -995,46 +995,6 @@ public override void Authenticate (Encoding encoding, ICredentials credentials, OnAuthenticated (message, cancellationToken); } - internal void ReplayConnect (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - CheckDisposed (); - - probed = ProbedCapabilities.None; - secure = false; - - engine.Uri = new Uri ($"pop://{host}:110"); - engine.Connect (new Pop3Stream (replayStream, ProtocolLogger), cancellationToken); - engine.QueryCapabilities (cancellationToken); - engine.Disconnected += OnEngineDisconnected; - OnConnected (host, 110, SecureSocketOptions.None); - } - - internal async Task ReplayConnectAsync (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - CheckDisposed (); - - probed = ProbedCapabilities.None; - secure = false; - - engine.Uri = new Uri ($"pop://{host}:110"); - await engine.ConnectAsync (new Pop3Stream (replayStream, ProtocolLogger), cancellationToken).ConfigureAwait (false); - await engine.QueryCapabilitiesAsync (cancellationToken).ConfigureAwait (false); - engine.Disconnected += OnEngineDisconnected; - OnConnected (host, 110, SecureSocketOptions.None); - } - internal static void ComputeDefaultValues (string host, ref int port, ref SecureSocketOptions options, out Uri uri, out bool starttls) { switch (options) { diff --git a/MailKit/Net/Smtp/AsyncSmtpClient.cs b/MailKit/Net/Smtp/AsyncSmtpClient.cs index b5c82ce93b..a36f4c682e 100644 --- a/MailKit/Net/Smtp/AsyncSmtpClient.cs +++ b/MailKit/Net/Smtp/AsyncSmtpClient.cs @@ -396,43 +396,6 @@ public override async Task AuthenticateAsync (Encoding encoding, ICredentials cr throw new NotSupportedException ("No compatible authentication mechanisms found."); } - internal async Task ReplayConnectAsync (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - CheckDisposed (); - - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - Stream = new SmtpStream (replayStream, ProtocolLogger); - capabilities = SmtpCapabilities.None; - AuthenticationMechanisms.Clear (); - uri = new Uri ($"smtp://{host}:25"); - secure = false; - MaxSize = 0; - - try { - // read the greeting - var response = await Stream.ReadResponseAsync (cancellationToken).ConfigureAwait (false); - - if (response.StatusCode != SmtpStatusCode.ServiceReady) - throw new SmtpCommandException (SmtpErrorCode.UnexpectedStatusCode, response.StatusCode, response.Response); - - // Send EHLO and get a list of supported extensions - await EhloAsync (cancellationToken).ConfigureAwait (false); - - connected = true; - } catch { - Stream.Dispose (); - Stream = null; - throw; - } - - OnConnected (host, 25, SecureSocketOptions.None); - } - async Task SslHandshakeAsync (SslStream ssl, string host, CancellationToken cancellationToken) { #if NET5_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER diff --git a/MailKit/Net/Smtp/SmtpClient.cs b/MailKit/Net/Smtp/SmtpClient.cs index b101b22a16..dac84c59b0 100644 --- a/MailKit/Net/Smtp/SmtpClient.cs +++ b/MailKit/Net/Smtp/SmtpClient.cs @@ -1172,43 +1172,6 @@ public override void Authenticate (Encoding encoding, ICredentials credentials, throw new NotSupportedException ("No compatible authentication mechanisms found."); } - internal void ReplayConnect (string host, Stream replayStream, CancellationToken cancellationToken = default) - { - CheckDisposed (); - - if (host == null) - throw new ArgumentNullException (nameof (host)); - - if (replayStream == null) - throw new ArgumentNullException (nameof (replayStream)); - - Stream = new SmtpStream (replayStream, ProtocolLogger); - capabilities = SmtpCapabilities.None; - AuthenticationMechanisms.Clear (); - uri = new Uri ($"smtp://{host}:25"); - secure = false; - MaxSize = 0; - - try { - // read the greeting - var response = Stream.ReadResponse (cancellationToken); - - if (response.StatusCode != SmtpStatusCode.ServiceReady) - throw new SmtpCommandException (SmtpErrorCode.UnexpectedStatusCode, response.StatusCode, response.Response); - - // Send EHLO and get a list of supported extensions - Ehlo (cancellationToken); - - connected = true; - } catch { - Stream.Dispose (); - Stream = null; - throw; - } - - OnConnected (host, 25, SecureSocketOptions.None); - } - internal static void ComputeDefaultValues (string host, ref int port, ref SecureSocketOptions options, out Uri uri, out bool starttls) { switch (options) { diff --git a/UnitTests/Net/Imap/ImapClientTests.cs b/UnitTests/Net/Imap/ImapClientTests.cs index dead474208..078062ea47 100644 --- a/UnitTests/Net/Imap/ImapClientTests.cs +++ b/UnitTests/Net/Imap/ImapClientTests.cs @@ -138,17 +138,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000003 LIST (SPECIAL-USE) \"\" \"*\" RETURN (SUBSCRIBED CHILDREN)\r\n", "dovecot.list-special-use.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); Assert.IsInstanceOf (client.SyncRoot, "SyncRoot"); - // ReplayConnect - Assert.Throws (() => client.ReplayConnect (null, Stream.Null)); - Assert.Throws (() => client.ReplayConnect ("host", null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync (null, Stream.Null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync ("host", null)); - // Connect Assert.Throws (() => client.Connect ((Uri) null)); Assert.ThrowsAsync (async () => await client.ConnectAsync ((Uri) null)); @@ -178,7 +172,7 @@ public void TestArgumentExceptions () } try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -337,7 +331,7 @@ static Socket Connect (string host, int port) [Test] public void TestSslHandshakeExceptions () { - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { Socket socket; // 1. Test connecting to a non-SSL port fails with an SslHandshakeException. @@ -381,7 +375,7 @@ public void TestSslHandshakeExceptions () [Test] public async Task TestSslHandshakeExceptionsAsync () { - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { Socket socket; // 1. Test connecting to a non-SSL port fails with an SslHandshakeException. @@ -952,9 +946,9 @@ public void TestGreetingCapabilities () new ImapReplayCommand ("", "common.capability-greeting.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -974,9 +968,9 @@ public async Task TestGreetingCapabilitiesAsync () new ImapReplayCommand ("", "common.capability-greeting.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -996,9 +990,9 @@ public void TestByeGreeting () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("The IMAP server unexpectedly refused the connection.", ex.Message); @@ -1017,9 +1011,9 @@ public async Task TestByeGreetingAsync () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("The IMAP server unexpectedly refused the connection.", ex.Message); @@ -1038,7 +1032,7 @@ public void TestByeGreetingWithAlert () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE [ALERT] Too many connections.\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int alerts = 0; client.Alert += (sender, e) => { @@ -1047,7 +1041,7 @@ public void TestByeGreetingWithAlert () }; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("Too many connections.", ex.Message); @@ -1068,7 +1062,7 @@ public async Task TestByeGreetingWithAlertAsync () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE [ALERT] Too many connections.\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int alerts = 0; client.Alert += (sender, e) => { @@ -1077,7 +1071,7 @@ public async Task TestByeGreetingWithAlertAsync () }; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("Too many connections.", ex.Message); @@ -1098,9 +1092,9 @@ public void TestByeGreetingWithRespText () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE Too many connections.\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("Too many connections.", ex.Message); @@ -1119,9 +1113,9 @@ public async Task TestByeGreetingWithRespTextAsync () new ImapReplayCommand ("", Encoding.ASCII.GetBytes ("* BYE Too many connections.\r\n")) }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to be connected."); } catch (ImapProtocolException ex) { Assert.AreEqual ("Too many connections.", ex.Message); @@ -1151,9 +1145,9 @@ public void TestUnexpectedBye () { var commands = CreateUnexpectedByeCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1182,9 +1176,9 @@ public async Task TestUnexpectedByeAsync () { var commands = CreateUnexpectedByeCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1221,9 +1215,9 @@ public void TestUnexpectedByeAfterCapability () { var commands = CreateUnexpectedByeAfterCapabilityCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to connect"); } catch (ImapProtocolException ex) { Assert.AreEqual ("Autologout; idle for too long (1)", ex.Message); @@ -1240,9 +1234,9 @@ public async Task TestUnexpectedByeAfterCapabilityAsync () { var commands = CreateUnexpectedByeAfterCapabilityCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); Assert.Fail ("Did not expect to connect"); } catch (ImapProtocolException ex) { Assert.AreEqual ("Autologout; idle for too long (1)", ex.Message); @@ -1272,7 +1266,7 @@ public void TestUnexpectedByeWithAlert () { var commands = CreateUnexpectedByeWithAlertCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int alerts = 0; client.Alert += (sender, e) => { @@ -1281,7 +1275,7 @@ public void TestUnexpectedByeWithAlert () }; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1312,7 +1306,7 @@ public async Task TestUnexpectedByeWithAlertAsync () { var commands = CreateUnexpectedByeWithAlertCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int alerts = 0; client.Alert += (sender, e) => { @@ -1321,7 +1315,7 @@ public async Task TestUnexpectedByeWithAlertAsync () }; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1361,9 +1355,9 @@ public void TestUnexpectedByeInSaslAuthenticate () { var commands = CreateUnexpectedByeInSaslAuthenticateCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1386,9 +1380,9 @@ public async Task TestUnexpectedByeInSaslAuthenticateAsync () { var commands = CreateUnexpectedByeInSaslAuthenticateCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1424,9 +1418,9 @@ public void TestInvalidTaggedByeDuringLogout () { var commands = CreateInvalidTaggedByeDuringLogoutCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1450,9 +1444,9 @@ public async Task TestInvalidTaggedByeDuringLogoutAsync () { var commands = CreateInvalidTaggedByeDuringLogoutCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect this exception in Connect: {0}", ex); } @@ -1487,14 +1481,14 @@ public void TestPreAuthGreeting () var capabilities = ImapCapabilities.IMAP4rev1 | ImapCapabilities.Status; var commands = CreatePreAuthGreetingCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int authenticated = 0; client.Authenticated += (sender, e) => { authenticated++; }; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1522,14 +1516,14 @@ public async Task TestPreAuthGreetingAsync () var capabilities = ImapCapabilities.IMAP4rev1 | ImapCapabilities.Status; var commands = CreatePreAuthGreetingCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int authenticated = 0; client.Authenticated += (sender, e) => { authenticated++; }; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1566,14 +1560,14 @@ public void TestPreAuthCapabilityGreeting () var capabilities = ImapCapabilities.IMAP4rev1 | ImapCapabilities.Status; var commands = CreatePreAuthCapabilityGreetingCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int authenticated = 0; client.Authenticated += (sender, e) => { authenticated++; }; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1601,14 +1595,14 @@ public async Task TestPreAuthCapabilityGreetingAsync () var capabilities = ImapCapabilities.IMAP4rev1 | ImapCapabilities.Status; var commands = CreatePreAuthCapabilityGreetingCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int authenticated = 0; client.Authenticated += (sender, e) => { authenticated++; }; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1647,7 +1641,7 @@ public void TestGMailWebAlert () var commands = CreateGMailWebAlertCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int webalerts = 0; int alerts = 0; @@ -1663,7 +1657,7 @@ public void TestGMailWebAlert () }; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1694,7 +1688,7 @@ public async Task TestGMailWebAlertAsync () var commands = CreateGMailWebAlertCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { int webalerts = 0; int alerts = 0; @@ -1710,7 +1704,7 @@ public async Task TestGMailWebAlertAsync () }; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1749,9 +1743,9 @@ public void TestUnicodeRespText () { var commands = CreateUnicodeRespTextCommands (out var respText); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1776,9 +1770,9 @@ public async Task TestUnicodeRespTextAsync () { var commands = CreateUnicodeRespTextCommands (out var respText); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1816,9 +1810,9 @@ public void TestInvalidUntaggedBadResponse () { var commands = CreateInvalidUntaggedBadResponseCommands (out var alertText); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1850,9 +1844,9 @@ public async Task TestInvalidUntaggedBadResponseAsync () { var commands = CreateInvalidUntaggedBadResponseCommands (out var alertText); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1896,9 +1890,9 @@ public void TestLogin () { var commands = CreateLoginCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1944,9 +1938,9 @@ public async Task TestLoginAsync () { var commands = CreateLoginCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2004,9 +1998,9 @@ public void TestLoginSpecialCharacter () { var commands = CreateLoginSpecialCharacterCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2052,9 +2046,9 @@ public async Task TestLoginSpecialCharacterAsync () { var commands = CreateLoginSpecialCharacterCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2109,9 +2103,9 @@ public void TestLoginDisabled () { var commands = CreateLoginDisabledCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2156,9 +2150,9 @@ public async Task TestLoginDisabledAsync () { var commands = CreateLoginDisabledCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2211,9 +2205,9 @@ public void TestExchangeUserIsAuthenticatedButNotConnected () { var commands = CreateExchangeUserIsAuthenticatedButNotConnectedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2246,9 +2240,9 @@ public async Task TestExchangeUserIsAuthenticatedButNotConnectedAsync () { var commands = CreateExchangeUserIsAuthenticatedButNotConnectedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2298,9 +2292,9 @@ public void TestAdvancedFeatures () { var commands = CreateAdvancedFeaturesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2372,9 +2366,9 @@ public async Task TestAdvancedFeaturesAsync () { var commands = CreateAdvancedFeaturesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2464,9 +2458,9 @@ public void TestSendingStringsAsLiterals () { var commands = CreateSendingStringsAsLiteralsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2502,9 +2496,9 @@ public async Task TestSendingStringsAsLiteralsAsync () { var commands = CreateSendingStringsAsLiteralsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2554,9 +2548,9 @@ public void TestSaslAuthentication () { var commands = CreateSaslAuthenticationCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2603,9 +2597,9 @@ public async Task TestSaslAuthenticationAsync () { var commands = CreateSaslAuthenticationCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2664,9 +2658,9 @@ public void TestSaslIRAuthentication () { var commands = CreateSaslIRAuthenticationCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2712,9 +2706,9 @@ public async Task TestSaslIRAuthenticationAsync () { var commands = CreateSaslIRAuthenticationCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2821,9 +2815,9 @@ public void TestRedactLogin () var commands = CreateRedactLoginCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2873,9 +2867,9 @@ public async Task TestRedactLoginAsync () var commands = CreateRedactLoginCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2937,9 +2931,9 @@ public void TestRedactAuthentication () var commands = CreateRedactAuthenticationCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2978,9 +2972,9 @@ public async Task TestRedactAuthenticationAsync () var commands = CreateRedactAuthenticationCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3033,9 +3027,9 @@ public void TestRedactSaslAuthentication () var commands = CreateRedactSaslAuthenticationCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3086,9 +3080,9 @@ public async Task TestRedactSaslAuthenticationAsync () var commands = CreateRedactSaslAuthenticationCommands (); using (var stream = new MemoryStream ()) { - using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true })) { + using (var client = new ImapClient (new ProtocolLogger (stream, true) { RedactSecrets = true }) { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3151,9 +3145,9 @@ public void TestEnableUTF8 () { var commands = CreateEnableUTF8Commands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3192,9 +3186,9 @@ public async Task TestEnableUTF8Async () { var commands = CreateEnableUTF8Commands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3245,9 +3239,9 @@ public void TestEnableQuickResync () { var commands = CreateEnableQuickResyncCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3287,9 +3281,9 @@ public async Task TestEnableQuickResyncAsync () { var commands = CreateEnableQuickResyncCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3379,9 +3373,9 @@ public void TestGetFolders () { var commands = CreateGetFoldersCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3487,9 +3481,9 @@ public async Task TestGetFoldersAsync () { var commands = CreateGetFoldersCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3609,9 +3603,9 @@ public void TestGetQuotaNonexistantQuotaRoot () { var commands = CreateGetQuotaNonexistantQuotaRootCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3660,9 +3654,9 @@ public async Task TestGetQuotaNonexistantQuotaRootAsync () { var commands = CreateGetQuotaNonexistantQuotaRootCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3854,9 +3848,9 @@ public void TestDovecot () var expectedPermanentFlags = expectedFlags | MessageFlags.UserDefined; var commands = CreateDovecotCommands (out var internalDates, out var messages, out var flags); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4502,9 +4496,9 @@ public async Task TestDovecotAsync () var expectedPermanentFlags = expectedFlags | MessageFlags.UserDefined; var commands = CreateDovecotCommands (out var internalDates, out var messages, out var flags); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5227,9 +5221,9 @@ public void TestGMail () { var commands = CreateGMailCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5392,9 +5386,9 @@ public async Task TestGMailAsync () { var commands = CreateGMailCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5573,9 +5567,9 @@ public void TestGetFolder () { var commands = CreateGetFolderCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5620,9 +5614,9 @@ public async Task TestGetFolderAsync () { var commands = CreateGetFolderCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5682,11 +5676,11 @@ public void TestIdentify () { var commands = CreateIdentifyCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { ImapImplementation implementation; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5761,11 +5755,11 @@ public async Task TestIdentifyAsync () { var commands = CreateIdentifyCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { ImapImplementation implementation; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5856,9 +5850,9 @@ public void TestIdle () { var commands = CreateIdleCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5918,9 +5912,9 @@ public async Task TestIdleAsync () { var commands = CreateIdleCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -5994,9 +5988,9 @@ public void TestIdleNotSupported () { var commands = CreateIdleNotSupportedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6028,9 +6022,9 @@ public async Task TestIdleNotSupportedAsync () { var commands = CreateIdleNotSupportedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6081,9 +6075,9 @@ public void TestNotify () const MessageSummaryItems items = MessageSummaryItems.UniqueId | MessageSummaryItems.Envelope | MessageSummaryItems.BodyStructure | MessageSummaryItems.Flags | MessageSummaryItems.ModSeq; var commands = CreateNotifyCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6281,9 +6275,9 @@ public async Task TestNotifyAsync () const MessageSummaryItems items = MessageSummaryItems.UniqueId | MessageSummaryItems.Envelope | MessageSummaryItems.BodyStructure | MessageSummaryItems.Flags | MessageSummaryItems.ModSeq; var commands = CreateNotifyCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6500,9 +6494,9 @@ public void TestCompress () { var commands = CreateCompressCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6546,9 +6540,9 @@ public async Task TestCompressAsync () { var commands = CreateCompressCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6611,9 +6605,9 @@ public void TestAccessControlLists () { var commands = CreateAccessControlListsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6710,9 +6704,9 @@ public async Task TestAccessControlListsAsync () { var commands = CreateAccessControlListsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6835,12 +6829,12 @@ public void TestMetadata () { var commands = CreateMetadataCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { MetadataCollection metadata; MetadataOptions options; try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -6963,12 +6957,12 @@ public async Task TestMetadataAsync () { var commands = CreateMetadataCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { MetadataCollection metadata; MetadataOptions options; try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -7104,9 +7098,9 @@ public void TestNamespaceExtensions () { var commands = CreateNamespaceExtensionCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -7140,9 +7134,9 @@ public async Task TestNamespaceExtensionsAsync () { var commands = CreateNamespaceExtensionCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -7183,9 +7177,9 @@ public void TestLowercaseImapResponses () new ImapReplayCommand ("A00000004 LIST (SPECIAL-USE) \"\" \"*\"\r\n", "lowercase.list.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Imap/ImapFolderAnnotationsTests.cs b/UnitTests/Net/Imap/ImapFolderAnnotationsTests.cs index d37f91a27e..9a1773b5f0 100644 --- a/UnitTests/Net/Imap/ImapFolderAnnotationsTests.cs +++ b/UnitTests/Net/Imap/ImapFolderAnnotationsTests.cs @@ -37,6 +37,7 @@ using MailKit; using MailKit.Search; +using MailKit.Security; using MailKit.Net.Imap; namespace UnitTests.Net.Imap { @@ -62,11 +63,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE ANNOTATE)\r\n", "common.select-inbox-annotate.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -140,11 +141,11 @@ public void TestNotSupportedExceptions () new ImapReplayCommand ("A00000005 SELECT INBOX (ANNOTATE)\r\n", "common.select-inbox-annotate-no-modseq.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -215,11 +216,11 @@ public void TestChangingAnnotationsOnEmptyListOfMessages () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE ANNOTATE)\r\n", "common.select-inbox-annotate.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -337,9 +338,9 @@ public void TestAppendWithAnnotations (bool withInternalDates) var commands = CreateAppendWithAnnotationsCommands (withInternalDates, out var messages, out var flags, out var internalDates, out var annotations); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -379,9 +380,9 @@ public async Task TestAppendWithAnnotationsAsync (bool withInternalDates) var commands = CreateAppendWithAnnotationsCommands (withInternalDates, out var messages, out var flags, out var internalDates, out var annotations); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -514,9 +515,9 @@ public void TestMultiAppendWithAnnotations (bool withInternalDates) var commands = CreateMultiAppendWithAnnotationsCommands (withInternalDates, out requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -563,9 +564,9 @@ public async Task TestMultiAppendWithAnnotationsAsync (bool withInternalDates) var commands = CreateMultiAppendWithAnnotationsCommands (withInternalDates, out requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -663,9 +664,9 @@ public void TestReplaceWithAnnotations () { var commands = CreateReplaceWithAnnotationsCommands (false, out var requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -698,9 +699,9 @@ public async Task TestReplaceWithAnnotationsAsync () { var commands = CreateReplaceWithAnnotationsCommands (false, out var requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -733,9 +734,9 @@ public void TestReplaceByUidWithAnnotations () { var commands = CreateReplaceWithAnnotationsCommands (true, out var requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -768,9 +769,9 @@ public async Task TestReplaceByUidWithAnnotationsAsync () { var commands = CreateReplaceWithAnnotationsCommands (true, out var requests); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -815,11 +816,11 @@ public void TestSelectAnnotateNone () { var commands = CreateSelectAnnotateNoneCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -851,11 +852,11 @@ public async Task TestSelectAnnotateNoneAsync () { var commands = CreateSelectAnnotateNoneCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -902,11 +903,11 @@ public void TestSearchAnnotations () { var commands = CreateSearchAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -948,11 +949,11 @@ public async Task TestSearchAnnotationsAsync () { var commands = CreateSearchAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1008,11 +1009,11 @@ public void TestSortAnnotations () { var commands = CreateSortAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1059,11 +1060,11 @@ public async Task TestSortAnnotationsAsync () { var commands = CreateSortAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1130,11 +1131,11 @@ public void TestStore () { var commands = CreateStoreCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1190,11 +1191,11 @@ public async Task TestStoreAsync () { var commands = CreateStoreCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Imap/ImapFolderFetchTests.cs b/UnitTests/Net/Imap/ImapFolderFetchTests.cs index 6f33558210..15cfc77016 100644 --- a/UnitTests/Net/Imap/ImapFolderFetchTests.cs +++ b/UnitTests/Net/Imap/ImapFolderFetchTests.cs @@ -39,6 +39,7 @@ using MimeKit; using MailKit; +using MailKit.Security; using MailKit.Net.Imap; namespace UnitTests.Net.Imap { @@ -102,11 +103,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE)\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -419,11 +420,11 @@ public void TestNotSupportedExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX\r\n", "common.select-inbox-no-modseq.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -508,9 +509,9 @@ public void TestFetchPreviewText () { var commands = CreateFetchPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -561,9 +562,9 @@ public async Task TestFetchPreviewTextAsync () { var commands = CreateFetchPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -632,9 +633,9 @@ public void TestFetchLazyPreviewText () { var commands = CreateFetchLazyPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -686,9 +687,9 @@ public async Task TestFetchLazyPreviewTextAsync () { var commands = CreateFetchLazyPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -776,9 +777,9 @@ public void TestFetchSimulatedPreviewText () { var commands = CreateFetchSimulatedPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -826,9 +827,9 @@ public async Task TestFetchSimulatedPreviewTextAsync () { var commands = CreateFetchSimulatedPreviewTextCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -891,9 +892,9 @@ public void TestExpungeDuringFetch () { var commands = CreateExpungeDuringFetchCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -940,9 +941,9 @@ public async Task TestExpungeDuringFetchAsync () { var commands = CreateExpungeDuringFetchCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1004,9 +1005,9 @@ public void TestExtractingPrecisePangolinAttachment () { var commands = CreateExtractingPrecisePangolinAttachmentCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1072,9 +1073,9 @@ public async Task TestExtractingPrecisePangolinAttachmentAsync () { var commands = CreateExtractingPrecisePangolinAttachmentCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1155,9 +1156,9 @@ public void TestFetchObjectIdAttributes () { var commands = CreateFetchObjectIdAttributesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1197,9 +1198,9 @@ public async Task TestFetchObjectIdAttributesAsync () { var commands = CreateFetchObjectIdAttributesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1254,9 +1255,9 @@ public void TestFetchSaveDate () { var commands = CreateFetchSaveDateCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1294,9 +1295,9 @@ public async Task TestFetchSaveDateAsync () { var commands = CreateFetchSaveDateCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1347,9 +1348,9 @@ public void TestFetchAnnotations () { var commands = CreateFetchAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1416,9 +1417,9 @@ public async Task TestFetchAnnotationsAsync () { var commands = CreateFetchAnnotationsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1499,9 +1500,9 @@ public void TestDominoParenthesisWorkaround () { var commands = CreateDominoParenthesisWorkaroundCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1546,9 +1547,9 @@ public async Task TestDominoParenthesisWorkaroundAsync () { var commands = CreateDominoParenthesisWorkaroundCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1609,9 +1610,9 @@ public void TestFetchStreamUnsolicitedInfo () { var commands = CreateFetchStreamUnsolicitedInfoCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1675,9 +1676,9 @@ public async Task TestFetchStreamUnsolicitedInfoAsync () { var commands = CreateFetchStreamUnsolicitedInfoCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Imap/ImapFolderFlagsTests.cs b/UnitTests/Net/Imap/ImapFolderFlagsTests.cs index 325497192d..94eab32bcf 100644 --- a/UnitTests/Net/Imap/ImapFolderFlagsTests.cs +++ b/UnitTests/Net/Imap/ImapFolderFlagsTests.cs @@ -31,6 +31,7 @@ using NUnit.Framework; using MailKit; +using MailKit.Security; using MailKit.Net.Imap; namespace UnitTests.Net.Imap { @@ -50,11 +51,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE)\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -219,7 +220,7 @@ public void TestArgumentExceptions () Assert.ThrowsAsync (() => inbox.StoreAsync (new int[] { 0 }, (StoreFlagsRequest) null)); var labels = new string [] { "Label1", "Label2" }; - var emptyLabels = new string[0]; + var emptyLabels = Array.Empty (); // AddLabels Assert.Throws (() => inbox.AddLabels (-1, labels, true)); @@ -347,11 +348,11 @@ public void TestNotSupportedExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX\r\n", "common.select-inbox-no-modseq.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -445,11 +446,11 @@ public void TestChangingFlagsOnEmptyListOfMessages () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE)\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -469,8 +470,8 @@ public void TestChangingFlagsOnEmptyListOfMessages () inbox.Open (FolderAccess.ReadWrite); ulong modseq = 409601020304; - var uids = new UniqueId[0]; - var indexes = new int[0]; + var uids = Array.Empty (); + var indexes = Array.Empty (); IList unmodifiedUids; IList unmodifiedIndexes; diff --git a/UnitTests/Net/Imap/ImapFolderSearchTests.cs b/UnitTests/Net/Imap/ImapFolderSearchTests.cs index 1282023c03..0c5a1630bf 100644 --- a/UnitTests/Net/Imap/ImapFolderSearchTests.cs +++ b/UnitTests/Net/Imap/ImapFolderSearchTests.cs @@ -34,6 +34,7 @@ using MailKit; using MailKit.Search; +using MailKit.Security; using MailKit.Net.Imap; namespace UnitTests.Net.Imap { @@ -52,11 +53,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE)\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -170,11 +171,11 @@ public void TestRawUnicodeSearch () { var commands = CreateRawUnicodeSearchCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -212,11 +213,11 @@ public async Task TestRawUnicodeSearchAsync () { var commands = CreateRawUnicodeSearchCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -267,11 +268,11 @@ public void TestSearchStringWithSpaces () { var commands = CreateSearchStringWithSpacesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -304,11 +305,11 @@ public async Task TestSearchStringWithSpacesAsync () { var commands = CreateSearchStringWithSpacesCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -357,11 +358,11 @@ public void TestSearchBadCharsetFallback () { var commands = CreateSearchBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -394,11 +395,11 @@ public async Task TestSearchBadCharsetFallbackAsync () { var commands = CreateSearchBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -447,11 +448,11 @@ public void TestSearchWithOptionsBadCharsetFallback () { var commands = CreateSearchWithOptionsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -490,11 +491,11 @@ public async Task TestSearchWithOptionsBadCharsetFallbackAsync () { var commands = CreateSearchWithOptionsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -549,11 +550,11 @@ public void TestSortBadCharsetFallback () { var commands = CreateSortBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -586,11 +587,11 @@ public async Task TestSortBadCharsetFallbackAsync () { var commands = CreateSortBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -639,11 +640,11 @@ public void TestSortWithOptionsBadCharsetFallback () { var commands = CreateSortWithOptionsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -682,11 +683,11 @@ public async Task TestSortWithOptionsBadCharsetFallbackAsync () { var commands = CreateSortWithOptionsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -743,11 +744,11 @@ public void TestThreadBadCharsetFallback () { var commands = CreateThreadBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -781,11 +782,11 @@ public async Task TestThreadBadCharsetFallbackAsync () { var commands = CreateThreadBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -835,11 +836,11 @@ public void TestThreadUidsBadCharsetFallback () { var commands = CreateThreadUidsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -873,11 +874,11 @@ public async Task TestThreadUidsBadCharsetFallbackAsync () { var commands = CreateThreadUidsBadCharsetFallbackCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Imap/ImapFolderTests.cs b/UnitTests/Net/Imap/ImapFolderTests.cs index db3d5949c4..baf4f8012c 100644 --- a/UnitTests/Net/Imap/ImapFolderTests.cs +++ b/UnitTests/Net/Imap/ImapFolderTests.cs @@ -37,6 +37,7 @@ using MailKit; using MailKit.Search; +using MailKit.Security; using MailKit.Net.Imap; namespace UnitTests.Net.Imap { @@ -81,11 +82,11 @@ public void TestArgumentExceptions () new ImapReplayCommand ("A00000004 SELECT INBOX (CONDSTORE)\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -373,11 +374,11 @@ public void TestNotSupportedExceptions () //new ImapReplayCommand ("A00000004 SELECT INBOX\r\n", "common.select-inbox.txt") }; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { var credentials = new NetworkCredential ("username", "password"); try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -579,9 +580,9 @@ public void TestAppend (bool withKeywords, bool withInternalDates) { var commands = CreateAppendCommands (withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -629,9 +630,9 @@ public async Task TestAppendAsync (bool withKeywords, bool withInternalDates) { var commands = CreateAppendCommands (withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -789,9 +790,9 @@ public void TestMultiAppend (bool withKeywords, bool withInternalDates) var commands = CreateMultiAppendCommands (withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); IList uids; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -873,9 +874,9 @@ public async Task TestMultiAppendAsync (bool withKeywords, bool withInternalDate var commands = CreateMultiAppendCommands (withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); IList uids; - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1045,9 +1046,9 @@ public void TestReplace (bool clientSide, bool withKeywords, bool withInternalDa { var commands = CreateReplaceCommands (clientSide, withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1110,9 +1111,9 @@ public async Task TestReplaceAsync (bool clientSide, bool withKeywords, bool wit { var commands = CreateReplaceCommands (clientSide, withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1263,9 +1264,9 @@ public void TestReplaceByUid (bool clientSide, bool withKeywords, bool withInter { var commands = CreateReplaceByUidCommands (clientSide, withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1328,9 +1329,9 @@ public async Task TestReplaceByUidAsync (bool clientSide, bool withKeywords, boo { var commands = CreateReplaceByUidCommands (clientSide, withKeywords, withInternalDates, out var messages, out var flags, out var keywords, out var internalDates); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1414,9 +1415,9 @@ public void TestCreateRenameDelete () { var commands = CreateCreateRenameDeleteCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1489,9 +1490,9 @@ public async Task TestCreateRenameDeleteAsync () { var commands = CreateCreateRenameDeleteCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1579,9 +1580,9 @@ public void TestCreateMailboxId () { var commands = CreateCreateMailboxIdCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1610,9 +1611,9 @@ public async Task TestCreateMailboxIdAsync () { var commands = CreateCreateMailboxIdCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1656,9 +1657,9 @@ public void TestCreateSpecialUse () { var commands = CreateCreateSpecialUseCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1690,9 +1691,9 @@ public async Task TestCreateSpecialUseAsync () { var commands = CreateCreateSpecialUseCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1740,9 +1741,9 @@ public void TestCreateSpecialUseMultiple () { var commands = CreateCreateSpecialUseMultipleCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1802,9 +1803,9 @@ public async Task TestCreateSpecialUseMultipleAsync () { var commands = CreateCreateSpecialUseMultipleCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1883,9 +1884,9 @@ public void TestCopyTo () { var commands = CreateCopyToCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1928,9 +1929,9 @@ public async Task TestCopyToAsync () { var commands = CreateCopyToCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1989,9 +1990,9 @@ public void TestExchangeCopyUidRespCodeWithoutOk () { var commands = CreateExchangeCopyUidRespCodeWithoutOkCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2029,9 +2030,9 @@ public async Task TestExchangeCopyUidRespCodeWithoutOkAsync () { var commands = CreateExchangeCopyUidRespCodeWithoutOkCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2098,9 +2099,9 @@ public void TestUidMoveTo (bool disableMove) { var commands = CreateMoveToCommands (disableMove); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2157,9 +2158,9 @@ public async Task TestUidMoveToAsync (bool disableMove) { var commands = CreateMoveToCommands (disableMove); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2243,9 +2244,9 @@ public void TestUidExpunge (bool disableUidPlus) { var commands = CreateUidExpungeCommands (disableUidPlus); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2289,9 +2290,9 @@ public async Task TestUidExpungeAsync (bool disableUidPlus) { var commands = CreateUidExpungeCommands (disableUidPlus); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2351,9 +2352,9 @@ public void TestExplicitCountChanged () { var commands = CreateExplicitCountChangedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2404,9 +2405,9 @@ public async Task TestExplicitCountChangedAsync () { var commands = CreateExplicitCountChangedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2474,9 +2475,9 @@ public void TestImplicitCountChanged () { var commands = CreateImplicitCountChangedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2527,9 +2528,9 @@ public async Task TestImplicitCountChangedAsync () { var commands = CreateImplicitCountChangedCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2619,9 +2620,9 @@ public void TestGetSubfoldersWithStatusItems () { var commands = CreateGetSubfoldersWithStatusItemsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - client.ReplayConnect ("localhost", new ImapReplayStream (commands, false)); + client.Connect (new ImapReplayStream (commands, false), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2686,9 +2687,9 @@ public async Task TestGetSuboldersWithStatusItemsAsync () { var commands = CreateGetSubfoldersWithStatusItemsCommands (); - using (var client = new ImapClient ()) { + using (var client = new ImapClient () { TagPrefix = 'A' }) { try { - await client.ReplayConnectAsync ("localhost", new ImapReplayStream (commands, true)); + await client.ConnectAsync (new ImapReplayStream (commands, true), "localhost", 143, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Pop3/Pop3ClientTests.cs b/UnitTests/Net/Pop3/Pop3ClientTests.cs index fddf66a50b..b83ad1d211 100644 --- a/UnitTests/Net/Pop3/Pop3ClientTests.cs +++ b/UnitTests/Net/Pop3/Pop3ClientTests.cs @@ -96,12 +96,6 @@ public void TestArgumentExceptions () using (var client = new Pop3Client ()) { var credentials = new NetworkCredential ("username", "password"); - // ReplayConnect - Assert.Throws (() => client.ReplayConnect (null, Stream.Null)); - Assert.Throws (() => client.ReplayConnect ("host", null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync (null, Stream.Null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync ("host", null)); - // Connect Assert.Throws (() => client.Connect ((Uri) null)); Assert.ThrowsAsync (async () => await client.ConnectAsync ((Uri) null)); @@ -359,7 +353,7 @@ public void TestInvalidStateExceptions () Assert.Throws (() => client.DeleteMessages (new int [] { 0 })); try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -488,7 +482,7 @@ public async Task TestInvalidStateExceptionsAsync () Assert.ThrowsAsync (async () => await client.DeleteMessagesAsync (new int[] { 0 })); try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1106,7 +1100,7 @@ public void TestGreetingOk () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1139,7 +1133,7 @@ public async Task TestGreetingOkAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1170,7 +1164,7 @@ public void TestGreetingErr () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); Assert.Fail ("Expected Connect to fail."); } catch (Pop3ProtocolException) { Assert.Pass (); @@ -1188,7 +1182,7 @@ public async Task TestGreetingErrAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); Assert.Fail ("Expected Connect to fail."); } catch (Pop3ProtocolException) { Assert.Pass (); @@ -1216,7 +1210,7 @@ public void TestBasicPop3Client () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1305,7 +1299,7 @@ public async Task TestBasicPop3ClientAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1394,7 +1388,7 @@ public void TestBasicPop3ClientUnixLineEndings () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, true)); + client.Connect (new Pop3ReplayStream (commands, false, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1480,7 +1474,7 @@ public async Task TestBasicPop3ClientUnixLineEndingsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, true)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1564,7 +1558,7 @@ public void TestProbedUidlSupport () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1616,7 +1610,7 @@ public async Task TestProbedUidlSupportAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1667,7 +1661,7 @@ public void TestProbedUidlSupportError () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1718,7 +1712,7 @@ public async Task TestProbedUidlSupportErrorAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1766,7 +1760,7 @@ public void TestEnableUTF8 () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1814,7 +1808,7 @@ public async Task TestEnableUTF8Async () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1864,7 +1858,7 @@ public void TestEnableUTF8AfterAuthenticate () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1920,7 +1914,7 @@ public async Task TestEnableUTF8AfterAuthenticateAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1973,7 +1967,7 @@ public void TestEnableUTF8NotSupported () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2016,7 +2010,7 @@ public async Task TestEnableUTF8NotSupportedAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2065,7 +2059,7 @@ public void TestGetMessageCountParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2128,7 +2122,7 @@ public async Task TestGetMessageCountParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2191,7 +2185,7 @@ public void TestGetMessageSizeParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2254,7 +2248,7 @@ public async Task TestGetMessageSizeParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2317,7 +2311,7 @@ public void TestGetMessageSizesParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2380,7 +2374,7 @@ public async Task TestGetMessageSizesParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2442,7 +2436,7 @@ public void TestGetMessageUidParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2498,7 +2492,7 @@ public async Task TestGetMessageUidParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2554,7 +2548,7 @@ public void TestGetMessageUidsParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2610,7 +2604,7 @@ public async Task TestGetMessageUidsParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2665,7 +2659,7 @@ public void TestSaslAuthentication () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2723,7 +2717,7 @@ public async Task TestSaslAuthenticationAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2825,7 +2819,7 @@ public void TestRedactApop () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2883,7 +2877,7 @@ public async Task TestRedactApopAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2942,7 +2936,7 @@ public void TestRedactAuthentication () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3005,7 +2999,7 @@ public async Task TestRedactAuthenticationAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3067,7 +3061,7 @@ public void TestRedactUserPass () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3123,7 +3117,7 @@ public async Task TestRedactUserPassAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3180,7 +3174,7 @@ public void TestRedactSaslAuthentication () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3242,7 +3236,7 @@ public async Task TestRedactSaslAuthenticationAsync () using (var stream = new MemoryStream ()) { using (var client = new Pop3Client (new ProtocolLogger (stream, true) { RedactSecrets = true })) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3305,7 +3299,7 @@ public void TestExchangePop3Client () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3382,7 +3376,7 @@ public async Task TestExchangePop3ClientAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3486,7 +3480,7 @@ void TestGMailPop3Client (List commands, bool disablePipelini { using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3732,7 +3726,7 @@ async Task TestGMailPop3ClientAsync (List commands, bool disa { using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4064,7 +4058,7 @@ public void TestGetEnumerator () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4123,7 +4117,7 @@ public void TestLangExtension () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4196,7 +4190,7 @@ public async Task TestLangExtensionAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4267,7 +4261,7 @@ public void TestLangNotSupported () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4322,7 +4316,7 @@ public void TestParseExceptions () using (var client = new Pop3Client ()) { try { - client.ReplayConnect ("localhost", new Pop3ReplayStream (commands, false, false)); + client.Connect (new Pop3ReplayStream (commands, false), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -4389,7 +4383,7 @@ public async Task TestParseExceptionsAsync () using (var client = new Pop3Client ()) { try { - await client.ReplayConnectAsync ("localhost", new Pop3ReplayStream (commands, true, false)); + await client.ConnectAsync (new Pop3ReplayStream (commands, true), "localhost", 110, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } diff --git a/UnitTests/Net/Smtp/SmtpClientTests.cs b/UnitTests/Net/Smtp/SmtpClientTests.cs index 018309a3d8..a4167184b3 100644 --- a/UnitTests/Net/Smtp/SmtpClientTests.cs +++ b/UnitTests/Net/Smtp/SmtpClientTests.cs @@ -129,14 +129,8 @@ public void TestArgumentExceptions () var message = CreateSimpleMessage (); var sender = message.From.Mailboxes.FirstOrDefault (); var recipients = message.To.Mailboxes.ToList (); + var empty = Array.Empty (); var options = FormatOptions.Default; - var empty = new MailboxAddress[0]; - - // ReplayConnect - Assert.Throws (() => client.ReplayConnect (null, Stream.Null)); - Assert.Throws (() => client.ReplayConnect ("host", null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync (null, Stream.Null)); - Assert.ThrowsAsync (async () => await client.ReplayConnectAsync ("host", null)); // Connect Assert.Throws (() => client.Connect ((Uri) null)); @@ -414,7 +408,7 @@ public void TestLocalDomainIPv4 () client.LocalDomain = "127.0.0.1"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -436,7 +430,7 @@ public void TestLocalDomainIPv6 () client.LocalDomain = "::1"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -458,7 +452,7 @@ public void TestLocalDomainIPv4MappedToIPv6 () client.LocalDomain = "::FFFF:129.144.52.38"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -483,7 +477,7 @@ public void TestSendWithoutSenderOrRecipients () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -509,7 +503,7 @@ public async Task TestSendWithoutSenderOrRecipientsAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -574,7 +568,7 @@ public void TestInvalidStateExceptions () Assert.Throws (() => client.Verify ("user@example.com")); try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -632,7 +626,7 @@ public async Task TestInvalidStateExceptionsAsync () Assert.ThrowsAsync (async () => await client.VerifyAsync ("user@example.com")); try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -667,12 +661,13 @@ public async Task TestInvalidStateExceptionsAsync () [Test] public void TestServiceNotReady () { - var commands = new List (); - commands.Add (new SmtpReplayCommand ("", "greeting-not-ready.txt")); + var commands = new List { + new SmtpReplayCommand ("", "greeting-not-ready.txt") + }; using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); Assert.Fail ("Connect is expected to fail."); } catch (SmtpCommandException ex) { Assert.AreEqual (SmtpErrorCode.UnexpectedStatusCode, ex.ErrorCode, "ErrorCode"); @@ -687,12 +682,13 @@ public void TestServiceNotReady () [Test] public async Task TestServiceNotReadyAsync () { - var commands = new List (); - commands.Add (new SmtpReplayCommand ("", "greeting-not-ready.txt")); + var commands = new List { + new SmtpReplayCommand ("", "greeting-not-ready.txt") + }; using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); Assert.Fail ("Connect is expected to fail."); } catch (SmtpCommandException ex) { Assert.AreEqual (SmtpErrorCode.UnexpectedStatusCode, ex.ErrorCode, "ErrorCode"); @@ -1229,17 +1225,18 @@ public async Task TestConnectYahooSocketAsync () [Test] public void TestSaslInitialResponse () { - var commands = new List (); - commands.Add (new SmtpReplayCommand ("", "comcast-greeting.txt")); - commands.Add (new SmtpReplayCommand ("EHLO unit-tests.mimekit.org\r\n", "comcast-ehlo.txt")); - commands.Add (new SmtpReplayCommand ("AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk\r\n", "comcast-auth-plain.txt")); - commands.Add (new SmtpReplayCommand ("QUIT\r\n", "comcast-quit.txt")); + var commands = new List { + new SmtpReplayCommand ("", "comcast-greeting.txt"), + new SmtpReplayCommand ("EHLO unit-tests.mimekit.org\r\n", "comcast-ehlo.txt"), + new SmtpReplayCommand ("AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk\r\n", "comcast-auth-plain.txt"), + new SmtpReplayCommand ("QUIT\r\n", "comcast-quit.txt") + }; using (var client = new SmtpClient ()) { client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1270,17 +1267,18 @@ public void TestSaslInitialResponse () [Test] public async Task TestSaslInitialResponseAsync () { - var commands = new List (); - commands.Add (new SmtpReplayCommand ("", "comcast-greeting.txt")); - commands.Add (new SmtpReplayCommand ("EHLO unit-tests.mimekit.org\r\n", "comcast-ehlo.txt")); - commands.Add (new SmtpReplayCommand ("AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk\r\n", "comcast-auth-plain.txt")); - commands.Add (new SmtpReplayCommand ("QUIT\r\n", "comcast-quit.txt")); + var commands = new List { + new SmtpReplayCommand ("", "comcast-greeting.txt"), + new SmtpReplayCommand ("EHLO unit-tests.mimekit.org\r\n", "comcast-ehlo.txt"), + new SmtpReplayCommand ("AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk\r\n", "comcast-auth-plain.txt"), + new SmtpReplayCommand ("QUIT\r\n", "comcast-quit.txt") + }; using (var client = new SmtpClient ()) { client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1331,7 +1329,7 @@ public void TestAuthenticationFailed () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1380,7 +1378,7 @@ public async Task TestAuthenticationFailedAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1479,7 +1477,7 @@ public void TestRedactAuthentication () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1522,7 +1520,7 @@ public async Task TestRedactAuthenticationAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1575,7 +1573,7 @@ public void TestRedactSaslInitialResponse () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1616,7 +1614,7 @@ public async Task TestRedactSaslInitialResponseAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1669,7 +1667,7 @@ public void TestRedactSaslAuthentication () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1710,7 +1708,7 @@ public async Task TestRedactSaslAuthenticationAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1755,7 +1753,7 @@ public void TestSmtpResponseModes (SmtpResponseMode mode) client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false, mode)); + client.Connect (new SmtpReplayStream (commands, false, mode), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1805,7 +1803,7 @@ public void TestHeloFallback () client.LocalDomain = "::1"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1833,7 +1831,7 @@ public async Task TestHeloFallbackAsync () client.LocalDomain = "::1"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -1892,7 +1890,7 @@ public void TestBasicFunctionality () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2029,7 +2027,7 @@ public async Task TestBasicFunctionalityAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2178,7 +2176,7 @@ public void TestSaslAuthentication () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2232,7 +2230,7 @@ public async Task TestSaslAuthenticationAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2298,7 +2296,7 @@ public void TestSaslExceptionProperlyResets () client.LocalDomain = "unit-tests.mimekit.org"; try { - client.ReplayConnect ("elwood.innosoft.com", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "elwood.innosoft.com", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2360,7 +2358,7 @@ public async Task TestSaslExceptionProperlyResetsAsync () client.LocalDomain = "unit-tests.mimekit.org"; try { - await client.ReplayConnectAsync ("elwood.innosoft.com", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "elwood.innosoft.com", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2434,7 +2432,7 @@ public void TestEightBitMime () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2481,7 +2479,7 @@ public async Task TestEightBitMimeAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2549,7 +2547,7 @@ public void TestInternationalMailboxes () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2607,7 +2605,7 @@ public async Task TestInternationalMailboxesAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2706,7 +2704,7 @@ public void TestBinaryMime (bool showProgress) using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2792,7 +2790,7 @@ public async Task TestBinaryMimeAsync (bool showProgress) using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2864,7 +2862,7 @@ public void TestPipelining (bool showProgress) using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2922,7 +2920,7 @@ public async Task TestPipeliningAsync (bool showProgress) using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -2991,7 +2989,7 @@ public void TestMailFromMailboxUnavailable () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3043,7 +3041,7 @@ public async Task TestMailFromMailboxUnavailableAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3108,7 +3106,7 @@ public void TestRcptToMailboxUnavailable () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3160,7 +3158,7 @@ public async Task TestRcptToMailboxUnavailableAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3242,7 +3240,7 @@ public void TestNoRecipientsAccepted () using (var client = new NoRecipientsAcceptedSmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3298,7 +3296,7 @@ public async Task TestNoRecipientsAcceptedAsync () using (var client = new NoRecipientsAcceptedSmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3366,7 +3364,7 @@ public void TestNoRecipientsAcceptedPipelined () using (var client = new NoRecipientsAcceptedSmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3422,7 +3420,7 @@ public async Task TestNoRecipientsAcceptedPipelinedAsync () using (var client = new NoRecipientsAcceptedSmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3489,7 +3487,7 @@ public void TestUnauthorizedAccessException () using (var client = new SmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3535,7 +3533,7 @@ public async Task TestUnauthorizedAccessExceptionAsync () using (var client = new SmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3629,7 +3627,7 @@ public void TestDeliveryStatusNotification () using (var client = new DsnSmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3687,7 +3685,7 @@ public async Task TestDeliveryStatusNotificationAsync () using (var client = new DsnSmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3756,7 +3754,7 @@ public void TestDeliveryStatusNotificationWithHexEncode () using (var client = new DsnSmtpClient ()) { try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3817,7 +3815,7 @@ public async Task TestDeliveryStatusNotificationWithHexEncodeAsync () using (var client = new DsnSmtpClient ()) { try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3905,7 +3903,7 @@ public void TestCustomCommand () Assert.Throws (() => client.SendCommand ("COMMAND")); try { - client.ReplayConnect ("localhost", new SmtpReplayStream (commands, false)); + client.Connect (new SmtpReplayStream (commands, false), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); } @@ -3968,7 +3966,7 @@ public async Task TestCustomCommandAsync () Assert.ThrowsAsync (async () => await client.SendCommandAsync ("COMMAND")); try { - await client.ReplayConnectAsync ("localhost", new SmtpReplayStream (commands, true)); + await client.ConnectAsync (new SmtpReplayStream (commands, true), "localhost", 25, SecureSocketOptions.None); } catch (Exception ex) { Assert.Fail ("Did not expect an exception in Connect: {0}", ex); }