PipeStreamTest.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Renci.SshNet.Common;
  3. using Renci.SshNet.Tests.Common;
  4. using System;
  5. using System.IO;
  6. namespace Renci.SshNet.Tests.Classes.Common
  7. {
  8. [TestClass]
  9. public class PipeStreamTest : TestBase
  10. {
  11. [TestMethod]
  12. [TestCategory("PipeStream")]
  13. public void Test_PipeStream_Write_Read_Buffer()
  14. {
  15. var testBuffer = new byte[1024];
  16. new Random().NextBytes(testBuffer);
  17. var outputBuffer = new byte[1024];
  18. using (var stream = new PipeStream())
  19. {
  20. stream.Write(testBuffer, 0, testBuffer.Length);
  21. Assert.AreEqual(stream.Length, testBuffer.Length);
  22. stream.Read(outputBuffer, 0, outputBuffer.Length);
  23. Assert.AreEqual(stream.Length, 0);
  24. Assert.IsTrue(testBuffer.IsEqualTo(outputBuffer));
  25. }
  26. }
  27. [TestMethod]
  28. [TestCategory("PipeStream")]
  29. public void Test_PipeStream_Write_Read_Byte()
  30. {
  31. var testBuffer = new byte[1024];
  32. new Random().NextBytes(testBuffer);
  33. var outputBuffer = new byte[1024];
  34. using (var stream = new PipeStream())
  35. {
  36. stream.Write(testBuffer, 0, testBuffer.Length);
  37. Assert.AreEqual(stream.Length, testBuffer.Length);
  38. stream.ReadByte();
  39. Assert.AreEqual(stream.Length, testBuffer.Length - 1);
  40. stream.ReadByte();
  41. Assert.AreEqual(stream.Length, testBuffer.Length - 2);
  42. }
  43. }
  44. /// <summary>
  45. ///A test for PipeStream Constructor
  46. ///</summary>
  47. [TestMethod()]
  48. public void PipeStreamConstructorTest()
  49. {
  50. PipeStream target = new PipeStream();
  51. Assert.Inconclusive("TODO: Implement code to verify target");
  52. }
  53. /// <summary>
  54. ///A test for Flush
  55. ///</summary>
  56. [TestMethod()]
  57. public void FlushTest()
  58. {
  59. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  60. target.Flush();
  61. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  62. }
  63. /// <summary>
  64. ///A test for Read
  65. ///</summary>
  66. [TestMethod()]
  67. public void ReadTest()
  68. {
  69. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  70. byte[] buffer = null; // TODO: Initialize to an appropriate value
  71. int offset = 0; // TODO: Initialize to an appropriate value
  72. int count = 0; // TODO: Initialize to an appropriate value
  73. int expected = 0; // TODO: Initialize to an appropriate value
  74. int actual;
  75. actual = target.Read(buffer, offset, count);
  76. Assert.AreEqual(expected, actual);
  77. Assert.Inconclusive("Verify the correctness of this test method.");
  78. }
  79. /// <summary>
  80. ///A test for Seek
  81. ///</summary>
  82. [TestMethod()]
  83. public void SeekTest()
  84. {
  85. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  86. long offset = 0; // TODO: Initialize to an appropriate value
  87. SeekOrigin origin = new SeekOrigin(); // TODO: Initialize to an appropriate value
  88. long expected = 0; // TODO: Initialize to an appropriate value
  89. long actual;
  90. actual = target.Seek(offset, origin);
  91. Assert.AreEqual(expected, actual);
  92. Assert.Inconclusive("Verify the correctness of this test method.");
  93. }
  94. /// <summary>
  95. ///A test for SetLength
  96. ///</summary>
  97. [TestMethod()]
  98. public void SetLengthTest()
  99. {
  100. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  101. long value = 0; // TODO: Initialize to an appropriate value
  102. target.SetLength(value);
  103. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  104. }
  105. /// <summary>
  106. ///A test for Write
  107. ///</summary>
  108. [TestMethod()]
  109. public void WriteTest()
  110. {
  111. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  112. byte[] buffer = null; // TODO: Initialize to an appropriate value
  113. int offset = 0; // TODO: Initialize to an appropriate value
  114. int count = 0; // TODO: Initialize to an appropriate value
  115. target.Write(buffer, offset, count);
  116. Assert.Inconclusive("A method that does not return a value cannot be verified.");
  117. }
  118. /// <summary>
  119. ///A test for BlockLastReadBuffer
  120. ///</summary>
  121. [TestMethod()]
  122. public void BlockLastReadBufferTest()
  123. {
  124. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  125. bool expected = false; // TODO: Initialize to an appropriate value
  126. bool actual;
  127. target.BlockLastReadBuffer = expected;
  128. actual = target.BlockLastReadBuffer;
  129. Assert.AreEqual(expected, actual);
  130. Assert.Inconclusive("Verify the correctness of this test method.");
  131. }
  132. /// <summary>
  133. ///A test for CanRead
  134. ///</summary>
  135. [TestMethod()]
  136. public void CanReadTest()
  137. {
  138. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  139. bool actual;
  140. actual = target.CanRead;
  141. Assert.Inconclusive("Verify the correctness of this test method.");
  142. }
  143. /// <summary>
  144. ///A test for CanSeek
  145. ///</summary>
  146. [TestMethod()]
  147. public void CanSeekTest()
  148. {
  149. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  150. bool actual;
  151. actual = target.CanSeek;
  152. Assert.Inconclusive("Verify the correctness of this test method.");
  153. }
  154. /// <summary>
  155. ///A test for CanWrite
  156. ///</summary>
  157. [TestMethod()]
  158. public void CanWriteTest()
  159. {
  160. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  161. bool actual;
  162. actual = target.CanWrite;
  163. Assert.Inconclusive("Verify the correctness of this test method.");
  164. }
  165. /// <summary>
  166. ///A test for Length
  167. ///</summary>
  168. [TestMethod()]
  169. public void LengthTest()
  170. {
  171. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  172. long actual;
  173. actual = target.Length;
  174. Assert.Inconclusive("Verify the correctness of this test method.");
  175. }
  176. /// <summary>
  177. ///A test for MaxBufferLength
  178. ///</summary>
  179. [TestMethod()]
  180. public void MaxBufferLengthTest()
  181. {
  182. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  183. long expected = 0; // TODO: Initialize to an appropriate value
  184. long actual;
  185. target.MaxBufferLength = expected;
  186. actual = target.MaxBufferLength;
  187. Assert.AreEqual(expected, actual);
  188. Assert.Inconclusive("Verify the correctness of this test method.");
  189. }
  190. /// <summary>
  191. ///A test for Position
  192. ///</summary>
  193. [TestMethod()]
  194. public void PositionTest()
  195. {
  196. PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
  197. long expected = 0; // TODO: Initialize to an appropriate value
  198. long actual;
  199. target.Position = expected;
  200. actual = target.Position;
  201. Assert.AreEqual(expected, actual);
  202. Assert.Inconclusive("Verify the correctness of this test method.");
  203. }
  204. }
  205. }