Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shell stream #1514

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Renci.SshNet/ShellStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,23 @@ public void WriteLine(string line)
Write(line + (_noTerminal ? "\n" : "\r"));
}

/// <summary>
/// Change the terminal size.
/// </summary>
/// <param name="columns">new columns of the terminal.</param>
/// <param name="rows">new rows of the terminal.</param>
/// <param name="width">new width of the terminal.</param>
/// <param name="height">new height of the terminal.</param>
/// <returns>
/// <see langword="true"/> if request was successful; otherwise <see langword="false"/>.
/// </returns>
public bool SendWindowChangeRequest(uint columns, uint rows, uint width, uint height)
{
ThrowHelper.ThrowObjectDisposedIf(_disposed, this);

return _channel.SendWindowChangeRequest(columns, rows, width, height);
}

/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
Expand Down
12 changes: 12 additions & 0 deletions test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public void Write_AfterDispose_ThrowsObjectDisposedException()
Assert.ThrowsException<ObjectDisposedException>(() => shellStream.Write(bytes, 0, bytes.Length));
}

[TestMethod]
public void SendWindowChangeRequest_ThrowsObjectDisposedException()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a simple test which verifies the call to ChannelSession.SendWindowChangeRequest?

{
var shellStream = CreateShellStream();

_channelSessionMock.Setup(p => p.Dispose());

shellStream.Dispose();

Assert.ThrowsException<ObjectDisposedException>(() => shellStream.SendWindowChangeRequest(80, 24, 0, 0));
}

private ShellStream CreateShellStream()
{
_sessionMock.Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
Expand Down