mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 09:15:47 +00:00
c7a0ca93de
These have started failing for me locally (Win11). SocketError.NoData means "The requested name or IP address was not found on the name server." which lines up with what we are testing here.
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using System.Net.Sockets;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace Renci.SshNet.Tests.Classes.Connection
|
|
{
|
|
[TestClass]
|
|
public class HttpConnectorTest_Connect_ProxyHostInvalid : HttpConnectorTestBase
|
|
{
|
|
private ConnectionInfo _connectionInfo;
|
|
private SocketException _actualException;
|
|
private Socket _clientSocket;
|
|
|
|
protected override void SetupData()
|
|
{
|
|
base.SetupData();
|
|
|
|
_connectionInfo = new ConnectionInfo("localhost",
|
|
40,
|
|
"user",
|
|
ProxyTypes.Http,
|
|
"invalid.",
|
|
80,
|
|
"proxyUser",
|
|
"proxyPwd",
|
|
new KeyboardInteractiveAuthenticationMethod("user"));
|
|
_actualException = null;
|
|
_clientSocket = SocketFactory.Create(SocketType.Stream, ProtocolType.Tcp);
|
|
}
|
|
|
|
protected override void SetupMocks()
|
|
{
|
|
_ = SocketFactoryMock.Setup(p => p.Create(SocketType.Stream, ProtocolType.Tcp))
|
|
.Returns(_clientSocket);
|
|
}
|
|
|
|
protected override void Act()
|
|
{
|
|
try
|
|
{
|
|
_ = Connector.Connect(_connectionInfo);
|
|
Assert.Fail();
|
|
}
|
|
catch (SocketException ex)
|
|
{
|
|
_actualException = ex;
|
|
}
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ConnectShouldHaveThrownSocketException()
|
|
{
|
|
Assert.IsNotNull(_actualException);
|
|
Assert.IsNull(_actualException.InnerException);
|
|
Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain or SocketError.NoData);
|
|
}
|
|
}
|
|
}
|