C
C#2y ago
Relevant

❔ Mock linux server

I'm trying to write some unit tests for an application I created that will ssh into several servers and check some configurations, etc. Is there a good way to mock this? Could I do some dummy server somehow, or mock a SshClient? I'm certainly not super experienced when it comes to unit testing. Would it be fine to just use Moq and give a SshClient/ShellStream a Setup and Returns to just return some dummy data back from the calls?
4 Replies
Relevant
RelevantOP2y ago
Well unfortunately, the SshClient is being created inside the method I'm testing. It takes in a ConnectionInfo object. So doing it that way, I'd need to pass it some ConnectionInfo to some fake server. So that probably complicates things.
Pixel
Pixel2y ago
ssh into your own system maybe or use a vm
Relevant
RelevantOP2y ago
Yeah, I was looking at MockServer and that seems pretty useful. But it would only exist locally for me, so no one else could run the tests https://www.mock-server.com/
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server