Skip to content

Commit 7513247

Browse files
committed
Doubled expectBuffer's default size and added a large expect test.
1 parent e9f65c2 commit 7513247

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Renci.SshNet/SshClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public Shell CreateShell(Encoding encoding, string input, Stream output, Stream
416416
/// </remarks>
417417
public ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize)
418418
{
419-
return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, (int)columns, terminalModeValues: null);
419+
return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, bufferSize * 2, terminalModeValues: null);
420420
}
421421

422422
/// <summary>
@@ -478,7 +478,7 @@ public ShellStream CreateShellStream(string terminalName, uint columns, uint row
478478
{
479479
EnsureSessionIsOpen();
480480

481-
return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, (int)columns, terminalModeValues);
481+
return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, bufferSize * 2, terminalModeValues);
482482
}
483483

484484
/// <summary>

test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void Initialize()
4343
height: 600,
4444
terminalModeValues: null,
4545
bufferSize: 1024,
46-
expectSize: 1024);
46+
expectSize: 2048);
4747
}
4848

4949
[TestMethod]
@@ -228,6 +228,22 @@ public void Expect_String_non_ASCII_characters()
228228
Assert.AreEqual("んにちは, Bonjour", _shellStream.Read());
229229
}
230230

231+
[TestMethod]
232+
public void Expect_String_LargeExpect()
233+
{
234+
_channelSessionStub.Receive(Encoding.UTF8.GetBytes(new string('a', 100)));
235+
for (var i = 0; i < 10; i++)
236+
{
237+
_channelSessionStub.Receive(Encoding.UTF8.GetBytes(new string('b', 100)));
238+
}
239+
_channelSessionStub.Receive(Encoding.UTF8.GetBytes("Hello, こんにちは, Bonjour"));
240+
_channelSessionStub.Receive(Encoding.UTF8.GetBytes(new string('c', 100)));
241+
242+
Assert.AreEqual($"{new string('a', 100)}{new string('b', 1000)}Hello, こんにちは, Bonjour", _shellStream.Expect($"{new string('b', 1000)}Hello, こんにちは, Bonjour"));
243+
244+
Assert.AreEqual($"{new string('c', 100)}", _shellStream.Read());
245+
}
246+
231247
[TestMethod]
232248
public void Expect_Timeout()
233249
{

0 commit comments

Comments
 (0)