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

Add interface to SftpClient. #193

Closed
ericbrumfield opened this issue Mar 7, 2017 · 9 comments
Closed

Add interface to SftpClient. #193

ericbrumfield opened this issue Mar 7, 2017 · 9 comments
Milestone

Comments

@ericbrumfield
Copy link
Contributor

This would be handy to have for testing and mocking and I'd like to contribute to this feature if possible.

@CasperWSchmidt
Copy link

CasperWSchmidt commented Nov 5, 2018

This really should be merged! Along with ISftpFile interface for SftpFile :)

In my project I have implemented wrappers with interfaces IFtpFileWrapper and IFtpClientWrapper to be able to separate SSH.Net from most of my classes and enable unit testing. But it is not very pretty :(

@drieseng drieseng added this to the 2020.0.0-beta2 milestone Jun 28, 2020
ericbrumfield added a commit to ericbrumfield/SSH.NET that referenced this issue Jun 28, 2020
ericbrumfield added a commit to ericbrumfield/SSH.NET that referenced this issue Jun 28, 2020
ericbrumfield added a commit to ericbrumfield/SSH.NET that referenced this issue Jun 28, 2020
Trekkan pushed a commit to Trekkan/SSH.NET that referenced this issue Mar 22, 2021
Add ISftpClient interface to **SftpClient for mocking and testing purposes.
Fixes sshnet#193.
@benjaminoerskov
Copy link

Im still having a hard time mocking some of the methods in the SftpClient.
I came across the method Connect() which does not exist in the Interface, but comes from the BaseClient.
Would it be possible to add such methods to the ISftpClient interface? Or how would you mock them?

@CasperWSchmidt
Copy link

@benjaminoerskov I would say that Connect is a pretty important part of the abstraction. An interface for communicating with a FTP server is not of much use if you can't connect to it 😊
Therefore I will argue that it obviously should be part of the interface

@polly-utopi
Copy link

Are there any plans to add the Connect method to the interface?

@lugospod
Copy link

lugospod commented Feb 7, 2022

@benjaminoerskov I would say that Connect is a pretty important part of the abstraction. An interface for communicating with a FTP server is not of much use if you can't connect to it 😊 Therefore I will argue that it obviously should be part of the interface

Yeap...connect should definitely be in the interface.

@sga-solita
Copy link

Im still having a hard time mocking some of the methods in the SftpClient. I came across the method Connect() which does not exist in the Interface, but comes from the BaseClient. Would it be possible to add such methods to the ISftpClient interface? Or how would you mock them?

I found this answer, because I'm sitting in the same situation. To be able to use SftpClient with Dependency Injection, I need to Connect when I inject the client into my dependent classes, which feels wrong. If something goes wrong with Connect, it shouldn't be thrown from the injecting part, but instead inside the dependent class. At least in my case.

@CasperWSchmidt
Copy link

All of this should be fixed in #975 but we're still waiting for it to be released

@berv63
Copy link

berv63 commented Aug 3, 2023

Can we get a readme update with some use cases on how to connect using the interface?

@CasperWSchmidt
Copy link

CasperWSchmidt commented Aug 5, 2023

@berv63 it's impossible as it is now, but exactly the same as using the class directly when this PR gets released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants