2
0

HttpConnectorTest_Connect_ProxyHostInvalid.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System.Net.Sockets;
  3. namespace Renci.SshNet.Tests.Classes.Connection
  4. {
  5. [TestClass]
  6. public class HttpConnectorTest_Connect_ProxyHostInvalid : HttpConnectorTestBase
  7. {
  8. private ConnectionInfo _connectionInfo;
  9. private SocketException _actualException;
  10. protected override void SetupData()
  11. {
  12. base.SetupData();
  13. _connectionInfo = new ConnectionInfo("localhost",
  14. 40,
  15. "user",
  16. ProxyTypes.Http,
  17. "invalid.",
  18. 80,
  19. "proxyUser",
  20. "proxyPwd",
  21. new KeyboardInteractiveAuthenticationMethod("user"));
  22. _actualException = null;
  23. }
  24. protected override void Act()
  25. {
  26. try
  27. {
  28. _ = Connector.Connect(_connectionInfo);
  29. Assert.Fail();
  30. }
  31. catch (SocketException ex)
  32. {
  33. _actualException = ex;
  34. }
  35. }
  36. [TestMethod]
  37. public void ConnectShouldHaveThrownSocketException()
  38. {
  39. Assert.IsNotNull(_actualException);
  40. Assert.IsNull(_actualException.InnerException);
  41. Assert.IsTrue(_actualException.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain);
  42. }
  43. }
  44. }