ConnectionInfoTest.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Tests.Common;
  3. using Renci.SshNet.Tests.Properties;
  4. using System;
  5. namespace Renci.SshNet.Tests.Classes
  6. {
  7. /// <summary>
  8. /// Represents remote connection information class.
  9. /// </summary>
  10. [TestClass]
  11. public class ConnectionInfoTest : TestBase
  12. {
  13. [TestMethod]
  14. [TestCategory("ConnectionInfo")]
  15. [Description("Pass null as proxy host.")]
  16. [Owner("Kenneth_aa")]
  17. [ExpectedException(typeof(ArgumentException))]
  18. public void Test_ConnectionInfo_ProxyHost_Null()
  19. {
  20. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, null, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  21. }
  22. [TestMethod]
  23. [TestCategory("ConnectionInfo")]
  24. [Description("Pass too large proxy port.")]
  25. [Owner("Kenneth_aa")]
  26. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  27. public void Test_ConnectionInfo_ProxyPort_Large()
  28. {
  29. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, Resources.HOST, int.MaxValue, Resources.USERNAME, Resources.PASSWORD, null);
  30. }
  31. [TestMethod]
  32. [TestCategory("ConnectionInfo")]
  33. [Description("Pass too small proxy port.")]
  34. [Owner("Kenneth_aa")]
  35. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  36. public void Test_ConnectionInfo_ProxyPort_Small()
  37. {
  38. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, Resources.HOST, int.MinValue, Resources.USERNAME, Resources.PASSWORD, null);
  39. }
  40. [TestMethod]
  41. [TestCategory("ConnectionInfo")]
  42. [Description("Pass a valid proxy port.")]
  43. [Owner("Kenneth_aa")]
  44. public void Test_ConnectionInfo_ProxyPort_Valid()
  45. {
  46. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  47. }
  48. [TestMethod]
  49. [TestCategory("ConnectionInfo")]
  50. [Description("Pass null as host.")]
  51. [Owner("Kenneth_aa")]
  52. [ExpectedException(typeof(ArgumentException))]
  53. public void Test_ConnectionInfo_Host_Null()
  54. {
  55. new ConnectionInfo(null, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  56. }
  57. [TestMethod]
  58. [TestCategory("ConnectionInfo")]
  59. [Description("Pass a valid host.")]
  60. [Owner("Kenneth_aa")]
  61. public void Test_ConnectionInfo_Host_Valid()
  62. {
  63. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  64. }
  65. [TestMethod]
  66. [TestCategory("ConnectionInfo")]
  67. [Description("Pass too large port.")]
  68. [Owner("Kenneth_aa")]
  69. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  70. public void Test_ConnectionInfo_Port_Large()
  71. {
  72. new ConnectionInfo(Resources.HOST, int.MaxValue, Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  73. }
  74. [TestMethod]
  75. [TestCategory("ConnectionInfo")]
  76. [Description("Pass too small port.")]
  77. [Owner("Kenneth_aa")]
  78. [ExpectedException(typeof(ArgumentOutOfRangeException))]
  79. public void Test_ConnectionInfo_Port_Small()
  80. {
  81. new ConnectionInfo(Resources.HOST, int.MinValue, Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  82. }
  83. [TestMethod]
  84. [TestCategory("ConnectionInfo")]
  85. [Description("Pass a valid port.")]
  86. [Owner("Kenneth_aa")]
  87. public void Test_ConnectionInfo_Port_Valid()
  88. {
  89. new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  90. }
  91. [TestMethod]
  92. [TestCategory("ConnectionInfo")]
  93. [Description("Pass null as session.")]
  94. [Owner("Kenneth_aa")]
  95. [ExpectedException(typeof(ArgumentNullException))]
  96. public void Test_ConnectionInfo_Authenticate_Null()
  97. {
  98. var ret = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
  99. ret.Authenticate(null);
  100. }
  101. /// <summary>
  102. ///A test for Timeout
  103. ///</summary>
  104. [TestMethod()]
  105. public void TimeoutTest()
  106. {
  107. string host = string.Empty; // TODO: Initialize to an appropriate value
  108. string username = string.Empty; // TODO: Initialize to an appropriate value
  109. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  110. ConnectionInfo target = new ConnectionInfo(host, username, authenticationMethods); // TODO: Initialize to an appropriate value
  111. TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value
  112. TimeSpan actual;
  113. target.Timeout = expected;
  114. actual = target.Timeout;
  115. Assert.AreEqual(expected, actual);
  116. Assert.Inconclusive("Verify the correctness of this test method.");
  117. }
  118. /// <summary>
  119. ///A test for RetryAttempts
  120. ///</summary>
  121. [TestMethod()]
  122. public void RetryAttemptsTest()
  123. {
  124. string host = string.Empty; // TODO: Initialize to an appropriate value
  125. string username = string.Empty; // TODO: Initialize to an appropriate value
  126. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  127. ConnectionInfo target = new ConnectionInfo(host, username, authenticationMethods); // TODO: Initialize to an appropriate value
  128. int expected = 0; // TODO: Initialize to an appropriate value
  129. int actual;
  130. target.RetryAttempts = expected;
  131. actual = target.RetryAttempts;
  132. Assert.AreEqual(expected, actual);
  133. Assert.Inconclusive("Verify the correctness of this test method.");
  134. }
  135. /// <summary>
  136. ///A test for MaxSessions
  137. ///</summary>
  138. [TestMethod()]
  139. public void MaxSessionsTest()
  140. {
  141. string host = string.Empty; // TODO: Initialize to an appropriate value
  142. string username = string.Empty; // TODO: Initialize to an appropriate value
  143. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  144. ConnectionInfo target = new ConnectionInfo(host, username, authenticationMethods); // TODO: Initialize to an appropriate value
  145. int expected = 0; // TODO: Initialize to an appropriate value
  146. int actual;
  147. target.MaxSessions = expected;
  148. actual = target.MaxSessions;
  149. Assert.AreEqual(expected, actual);
  150. Assert.Inconclusive("Verify the correctness of this test method.");
  151. }
  152. /// <summary>
  153. ///A test for Authenticate
  154. ///</summary>
  155. [TestMethod()]
  156. public void AuthenticateTest()
  157. {
  158. string host = string.Empty; // TODO: Initialize to an appropriate value
  159. string username = string.Empty; // TODO: Initialize to an appropriate value
  160. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  161. ConnectionInfo target = new ConnectionInfo(host, username, authenticationMethods); // TODO: Initialize to an appropriate value
  162. Session session = null; // TODO: Initialize to an appropriate value
  163. target.Authenticate(session);
  164. Assert.Inconclusive("Verify the correctness of this test method.");
  165. }
  166. /// <summary>
  167. ///A test for ConnectionInfo Constructor
  168. ///</summary>
  169. [TestMethod()]
  170. public void ConnectionInfoConstructorTest()
  171. {
  172. string host = string.Empty; // TODO: Initialize to an appropriate value
  173. int port = 0; // TODO: Initialize to an appropriate value
  174. string username = string.Empty; // TODO: Initialize to an appropriate value
  175. ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
  176. string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
  177. int proxyPort = 0; // TODO: Initialize to an appropriate value
  178. string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
  179. string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
  180. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  181. ConnectionInfo target = new ConnectionInfo(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, authenticationMethods);
  182. Assert.Inconclusive("TODO: Implement code to verify target");
  183. }
  184. /// <summary>
  185. ///A test for ConnectionInfo Constructor
  186. ///</summary>
  187. [TestMethod()]
  188. public void ConnectionInfoConstructorTest1()
  189. {
  190. string host = string.Empty; // TODO: Initialize to an appropriate value
  191. int port = 0; // TODO: Initialize to an appropriate value
  192. string username = string.Empty; // TODO: Initialize to an appropriate value
  193. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  194. ConnectionInfo target = new ConnectionInfo(host, port, username, authenticationMethods);
  195. Assert.Inconclusive("TODO: Implement code to verify target");
  196. }
  197. /// <summary>
  198. ///A test for ConnectionInfo Constructor
  199. ///</summary>
  200. [TestMethod()]
  201. public void ConnectionInfoConstructorTest2()
  202. {
  203. string host = string.Empty; // TODO: Initialize to an appropriate value
  204. string username = string.Empty; // TODO: Initialize to an appropriate value
  205. AuthenticationMethod[] authenticationMethods = null; // TODO: Initialize to an appropriate value
  206. ConnectionInfo target = new ConnectionInfo(host, username, authenticationMethods);
  207. Assert.Inconclusive("TODO: Implement code to verify target");
  208. }
  209. }
  210. }