| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | using System.Net.Sockets;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace Renci.SshNet.Tests.Classes{    [TestClass]    public class SftpClientTest_Connect    {        [TestMethod]        public void Connect_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()        {            var connectionInfo = new ConnectionInfo("invalid.", 40, "user",                new KeyboardInteractiveAuthenticationMethod("user"));            var sftpClient = new SftpClient(connectionInfo);            try            {                sftpClient.Connect();                Assert.Fail();            }            catch (SocketException ex)            {                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);            }        }        [TestMethod]        public void Connect_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()        {            var connectionInfo = new ConnectionInfo("localhost", 40, "user", ProxyTypes.Http, "invalid.", 80,                "proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user"));            var sftpClient = new SftpClient(connectionInfo);            try            {                sftpClient.Connect();                Assert.Fail();            }            catch (SocketException ex)            {                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);            }        }    }}
 |