NetConfClientTest.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Tests.Common;
  3. using System;
  4. using System.Xml;
  5. namespace Renci.SshNet.Tests.Classes
  6. {
  7. [TestClass]
  8. public class NetConfClientTest : TestBase
  9. {
  10. private Random _random;
  11. [TestInitialize]
  12. public void SetUp()
  13. {
  14. _random = new Random();
  15. }
  16. [TestMethod]
  17. public void OperationTimeout_Default()
  18. {
  19. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  20. var target = new NetConfClient(connectionInfo);
  21. var actual = target.OperationTimeout;
  22. Assert.AreEqual(TimeSpan.FromMilliseconds(-1), actual);
  23. }
  24. [TestMethod]
  25. public void OperationTimeout_InsideLimits()
  26. {
  27. var operationTimeout = TimeSpan.FromMilliseconds(_random.Next(0, int.MaxValue - 1));
  28. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  29. var target = new NetConfClient(connectionInfo)
  30. {
  31. OperationTimeout = operationTimeout
  32. };
  33. var actual = target.OperationTimeout;
  34. Assert.AreEqual(operationTimeout, actual);
  35. }
  36. [TestMethod]
  37. public void OperationTimeout_LowerLimit()
  38. {
  39. var operationTimeout = TimeSpan.FromMilliseconds(-1);
  40. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  41. var target = new NetConfClient(connectionInfo)
  42. {
  43. OperationTimeout = operationTimeout
  44. };
  45. var actual = target.OperationTimeout;
  46. Assert.AreEqual(operationTimeout, actual);
  47. }
  48. [TestMethod]
  49. public void OperationTimeout_UpperLimit()
  50. {
  51. var operationTimeout = TimeSpan.FromMilliseconds(int.MaxValue);
  52. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  53. var target = new NetConfClient(connectionInfo)
  54. {
  55. OperationTimeout = operationTimeout
  56. };
  57. var actual = target.OperationTimeout;
  58. Assert.AreEqual(operationTimeout, actual);
  59. }
  60. [TestMethod]
  61. public void OperationTimeout_LessThanLowerLimit()
  62. {
  63. var operationTimeout = TimeSpan.FromMilliseconds(-2);
  64. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  65. var target = new NetConfClient(connectionInfo);
  66. try
  67. {
  68. target.OperationTimeout = operationTimeout;
  69. }
  70. catch (ArgumentOutOfRangeException ex)
  71. {
  72. Assert.IsNull(ex.InnerException);
  73. ArgumentExceptionAssert.MessageEquals("The timeout must represent a value between -1 and Int32.MaxValue, inclusive.", ex);
  74. Assert.AreEqual("value", ex.ParamName);
  75. }
  76. }
  77. [TestMethod]
  78. public void OperationTimeout_GreaterThanLowerLimit()
  79. {
  80. var operationTimeout = TimeSpan.FromMilliseconds(int.MaxValue).Add(TimeSpan.FromMilliseconds(1));
  81. var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd");
  82. var target = new NetConfClient(connectionInfo);
  83. try
  84. {
  85. target.OperationTimeout = operationTimeout;
  86. }
  87. catch (ArgumentOutOfRangeException ex)
  88. {
  89. Assert.IsNull(ex.InnerException);
  90. ArgumentExceptionAssert.MessageEquals("The timeout must represent a value between -1 and Int32.MaxValue, inclusive.", ex);
  91. Assert.AreEqual("value", ex.ParamName);
  92. }
  93. }
  94. /// <summary>
  95. ///A test for NetConfClient Constructor
  96. ///</summary>
  97. [TestMethod]
  98. [Ignore] // placeholder for actual test
  99. public void NetConfClientConstructorTest()
  100. {
  101. string host = string.Empty; // TODO: Initialize to an appropriate value
  102. string username = string.Empty; // TODO: Initialize to an appropriate value
  103. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  104. NetConfClient target = new NetConfClient(host, username, keyFiles);
  105. Assert.Inconclusive("TODO: Implement code to verify target");
  106. }
  107. /// <summary>
  108. ///A test for NetConfClient Constructor
  109. ///</summary>
  110. [TestMethod]
  111. [Ignore] // placeholder for actual test
  112. public void NetConfClientConstructorTest1()
  113. {
  114. string host = string.Empty; // TODO: Initialize to an appropriate value
  115. int port = 0; // TODO: Initialize to an appropriate value
  116. string username = string.Empty; // TODO: Initialize to an appropriate value
  117. PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value
  118. NetConfClient target = new NetConfClient(host, port, username, keyFiles);
  119. Assert.Inconclusive("TODO: Implement code to verify target");
  120. }
  121. /// <summary>
  122. ///A test for NetConfClient Constructor
  123. ///</summary>
  124. [TestMethod]
  125. [Ignore] // placeholder for actual test
  126. public void NetConfClientConstructorTest2()
  127. {
  128. string host = string.Empty; // TODO: Initialize to an appropriate value
  129. string username = string.Empty; // TODO: Initialize to an appropriate value
  130. string password = string.Empty; // TODO: Initialize to an appropriate value
  131. NetConfClient target = new NetConfClient(host, username, password);
  132. Assert.Inconclusive("TODO: Implement code to verify target");
  133. }
  134. /// <summary>
  135. ///A test for NetConfClient Constructor
  136. ///</summary>
  137. [TestMethod]
  138. [Ignore] // placeholder for actual test
  139. public void NetConfClientConstructorTest3()
  140. {
  141. string host = string.Empty; // TODO: Initialize to an appropriate value
  142. int port = 0; // TODO: Initialize to an appropriate value
  143. string username = string.Empty; // TODO: Initialize to an appropriate value
  144. string password = string.Empty; // TODO: Initialize to an appropriate value
  145. NetConfClient target = new NetConfClient(host, port, username, password);
  146. Assert.Inconclusive("TODO: Implement code to verify target");
  147. }
  148. /// <summary>
  149. ///A test for NetConfClient Constructor
  150. ///</summary>
  151. [TestMethod]
  152. [Ignore] // placeholder for actual test
  153. public void NetConfClientConstructorTest4()
  154. {
  155. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  156. NetConfClient target = new NetConfClient(connectionInfo);
  157. Assert.Inconclusive("TODO: Implement code to verify target");
  158. }
  159. /// <summary>
  160. ///A test for SendReceiveRpc
  161. ///</summary>
  162. [TestMethod]
  163. [Ignore] // placeholder for actual test
  164. public void SendReceiveRpcTest()
  165. {
  166. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  167. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  168. string xml = string.Empty; // TODO: Initialize to an appropriate value
  169. XmlDocument expected = null; // TODO: Initialize to an appropriate value
  170. XmlDocument actual;
  171. actual = target.SendReceiveRpc(xml);
  172. Assert.AreEqual(expected, actual);
  173. Assert.Inconclusive("Verify the correctness of this test method.");
  174. }
  175. /// <summary>
  176. ///A test for SendReceiveRpc
  177. ///</summary>
  178. [TestMethod]
  179. [Ignore] // placeholder for actual test
  180. public void SendReceiveRpcTest1()
  181. {
  182. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  183. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  184. XmlDocument rpc = null; // TODO: Initialize to an appropriate value
  185. XmlDocument expected = null; // TODO: Initialize to an appropriate value
  186. XmlDocument actual;
  187. actual = target.SendReceiveRpc(rpc);
  188. Assert.AreEqual(expected, actual);
  189. Assert.Inconclusive("Verify the correctness of this test method.");
  190. }
  191. /// <summary>
  192. ///A test for SendCloseRpc
  193. ///</summary>
  194. [TestMethod]
  195. [Ignore] // placeholder for actual test
  196. public void SendCloseRpcTest()
  197. {
  198. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  199. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  200. XmlDocument expected = null; // TODO: Initialize to an appropriate value
  201. XmlDocument actual;
  202. actual = target.SendCloseRpc();
  203. Assert.AreEqual(expected, actual);
  204. Assert.Inconclusive("Verify the correctness of this test method.");
  205. }
  206. /// <summary>
  207. ///A test for ServerCapabilities
  208. ///</summary>
  209. [TestMethod]
  210. [Ignore] // placeholder for actual test
  211. public void ServerCapabilitiesTest()
  212. {
  213. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  214. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  215. XmlDocument actual;
  216. actual = target.ServerCapabilities;
  217. Assert.Inconclusive("Verify the correctness of this test method.");
  218. }
  219. /// <summary>
  220. ///A test for ClientCapabilities
  221. ///</summary>
  222. [TestMethod]
  223. [Ignore] // placeholder for actual test
  224. public void ClientCapabilitiesTest()
  225. {
  226. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  227. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  228. XmlDocument actual;
  229. actual = target.ClientCapabilities;
  230. Assert.Inconclusive("Verify the correctness of this test method.");
  231. }
  232. /// <summary>
  233. ///A test for AutomaticMessageIdHandling
  234. ///</summary>
  235. [TestMethod]
  236. [Ignore] // placeholder for actual test
  237. public void AutomaticMessageIdHandlingTest()
  238. {
  239. ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
  240. NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value
  241. bool expected = false; // TODO: Initialize to an appropriate value
  242. bool actual;
  243. target.AutomaticMessageIdHandling = expected;
  244. actual = target.AutomaticMessageIdHandling;
  245. Assert.AreEqual(expected, actual);
  246. Assert.Inconclusive("Verify the correctness of this test method.");
  247. }
  248. }
  249. }