| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | using System;using System.Net.Sockets;using System.Threading.Tasks;using Microsoft.VisualStudio.TestTools.UnitTesting;namespace Renci.SshNet.Tests.Classes{    public partial class SftpClientTest    {        [TestMethod]        public async Task ConnectAsync_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()        {            var connectionInfo = new ConnectionInfo(Guid.NewGuid().ToString("N"), 40, "user",                new KeyboardInteractiveAuthenticationMethod("user"));            var sftpClient = new SftpClient(connectionInfo);            try            {                await sftpClient.ConnectAsync(default);                Assert.Fail();            }            catch (SocketException ex)            {                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}");            }        }        [TestMethod]        public async Task ConnectAsync_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()        {            var connectionInfo = new ConnectionInfo("localhost", 40, "user", ProxyTypes.Http, Guid.NewGuid().ToString("N"), 80,                "proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user"));            var sftpClient = new SftpClient(connectionInfo);            try            {                await sftpClient.ConnectAsync(default);                Assert.Fail();            }            catch (SocketException ex)            {                Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}");            }        }    }}
 |