public void TestArgumentExceptions () { using (var client = new Pop3Client ()) { var credentials = new NetworkCredential ("username", "password"); var socket = new Socket (SocketType.Stream, ProtocolType.Tcp); // Connect Assert.Throws<ArgumentNullException> (() => client.Connect ((Uri) null)); Assert.Throws<ArgumentNullException> (async () => await client.ConnectAsync ((Uri) null)); Assert.Throws<ArgumentNullException> (() => client.Connect (null, 110, false)); Assert.Throws<ArgumentNullException> (async () => await client.ConnectAsync (null, 110, false)); Assert.Throws<ArgumentException> (() => client.Connect (string.Empty, 110, false)); Assert.Throws<ArgumentException> (async () => await client.ConnectAsync (string.Empty, 110, false)); Assert.Throws<ArgumentOutOfRangeException> (() => client.Connect ("host", -1, false)); Assert.Throws<ArgumentOutOfRangeException> (async () => await client.ConnectAsync ("host", -1, false)); Assert.Throws<ArgumentNullException> (() => client.Connect (null, 110, SecureSocketOptions.None)); Assert.Throws<ArgumentNullException> (async () => await client.ConnectAsync (null, 110, SecureSocketOptions.None)); Assert.Throws<ArgumentException> (() => client.Connect (string.Empty, 110, SecureSocketOptions.None)); Assert.Throws<ArgumentException> (async () => await client.ConnectAsync (string.Empty, 110, SecureSocketOptions.None)); Assert.Throws<ArgumentOutOfRangeException> (() => client.Connect ("host", -1, SecureSocketOptions.None)); Assert.Throws<ArgumentOutOfRangeException> (async () => await client.ConnectAsync ("host", -1, SecureSocketOptions.None)); Assert.Throws<ArgumentNullException> (() => client.Connect (null, "host", 110, SecureSocketOptions.None)); Assert.Throws<ArgumentException> (() => client.Connect (socket, "host", 110, SecureSocketOptions.None)); // Authenticate Assert.Throws<ArgumentNullException> (() => client.Authenticate (null)); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (null)); Assert.Throws<ArgumentNullException> (() => client.Authenticate (null, "password")); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (null, "password")); Assert.Throws<ArgumentNullException> (() => client.Authenticate ("username", null)); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync ("username", null)); Assert.Throws<ArgumentNullException> (() => client.Authenticate (null, credentials)); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (null, credentials)); Assert.Throws<ArgumentNullException> (() => client.Authenticate (Encoding.UTF8, null)); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (Encoding.UTF8, null)); Assert.Throws<ArgumentNullException> (() => client.Authenticate (null, "username", "password")); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (null, "username", "password")); Assert.Throws<ArgumentNullException> (() => client.Authenticate (Encoding.UTF8, null, "password")); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (Encoding.UTF8, null, "password")); Assert.Throws<ArgumentNullException> (() => client.Authenticate (Encoding.UTF8, "username", null)); Assert.Throws<ArgumentNullException> (async () => await client.AuthenticateAsync (Encoding.UTF8, "username", null)); Assert.Throws<ArgumentNullException> (() => client.SetLanguage (null)); Assert.Throws<ArgumentNullException> (async () => await client.SetLanguageAsync (null)); Assert.Throws<ArgumentException> (() => client.SetLanguage (string.Empty)); Assert.Throws<ArgumentException> (async () => await client.SetLanguageAsync (string.Empty)); } }