0 votes
by (180 points)

hi all!
I'm trying to test service that using Rebex.Net.Ssh.
inside this service I use LoginAsync(username, pass) and ConnectAsync(host, port).

I've wrote this:

var sshMock = Mock.Of<Ssh>(m => m.IsConnected == true);
Mock.Get(sshMock).Setup(x => x.LoginAsync(It.IsAny<string>(), It.IsAny<int>())).Returns(Task.CompletedTask);

but faced with error - Exception thrown: 'System.NotSupportedException' in Moq.dll

What is the best way to write test with ssh components?
thank you in advance!

1 Answer

0 votes
by (144k points)

Hi,
We recommend implementing a wrapper class around the Ssh class that only provides the functionality you need in your application, and mock that.

Another option is to use https://github.com/StefH/ProxyInterfaceSourceGenerator to generate proxy classes and mock those.

...