Skip to content

Commit 75f6911

Browse files
committed
Implement tests for Length and MaxBufferLength.
1 parent 351e3c0 commit 75f6911

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

src/Renci.SshNet.Tests/Classes/Common/PipeStreamTest.cs

+14-38
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,16 @@ public void Test_PipeStream_Write_Read_Byte()
4040
var testBuffer = new byte[1024];
4141
new Random().NextBytes(testBuffer);
4242

43-
var outputBuffer = new byte[1024];
44-
4543
using (var stream = new PipeStream())
4644
{
4745
stream.Write(testBuffer, 0, testBuffer.Length);
48-
4946
Assert.AreEqual(stream.Length, testBuffer.Length);
50-
5147
stream.ReadByte();
52-
5348
Assert.AreEqual(stream.Length, testBuffer.Length - 1);
54-
5549
stream.ReadByte();
56-
5750
Assert.AreEqual(stream.Length, testBuffer.Length - 2);
5851
}
5952
}
60-
/// <summary>
61-
///A test for PipeStream Constructor
62-
///</summary>
63-
[TestMethod]
64-
public void PipeStreamConstructorTest()
65-
{
66-
PipeStream target = new PipeStream();
67-
Assert.Inconclusive("TODO: Implement code to verify target");
68-
}
69-
70-
/// <summary>
71-
///A test for Flush
72-
///</summary>
73-
[TestMethod]
74-
public void FlushTest()
75-
{
76-
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
77-
target.Flush();
78-
Assert.Inconclusive("A method that does not return a value cannot be verified.");
79-
}
8053

8154
[TestMethod]
8255
public void Read()
@@ -190,10 +163,16 @@ public void CanWriteTest()
190163
[TestMethod]
191164
public void LengthTest()
192165
{
193-
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
194-
long actual;
195-
actual = target.Length;
196-
Assert.Inconclusive("Verify the correctness of this test method.");
166+
var target = new PipeStream();
167+
Assert.AreEqual(0L, target.Length);
168+
target.Write(new byte[] { 0x0a, 0x05, 0x0d }, 0, 2);
169+
Assert.AreEqual(2L, target.Length);
170+
target.WriteByte(0x0a);
171+
Assert.AreEqual(3L, target.Length);
172+
target.Read(new byte[2], 0, 2);
173+
Assert.AreEqual(1L, target.Length);
174+
target.ReadByte();
175+
Assert.AreEqual(0L, target.Length);
197176
}
198177

199178
/// <summary>
@@ -202,13 +181,10 @@ public void LengthTest()
202181
[TestMethod]
203182
public void MaxBufferLengthTest()
204183
{
205-
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
206-
long expected = 0; // TODO: Initialize to an appropriate value
207-
long actual;
208-
target.MaxBufferLength = expected;
209-
actual = target.MaxBufferLength;
210-
Assert.AreEqual(expected, actual);
211-
Assert.Inconclusive("Verify the correctness of this test method.");
184+
var target = new PipeStream();
185+
Assert.AreEqual(200 * 1024 * 1024, target.MaxBufferLength);
186+
target.MaxBufferLength = 0L;
187+
Assert.AreEqual(0L, target.MaxBufferLength);
212188
}
213189

214190
[TestMethod]

0 commit comments

Comments
 (0)