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 Methods to ISftpClient to make Moq Testable #1015

Closed
Pieeer1 opened this issue Oct 20, 2022 · 3 comments
Closed

Add Methods to ISftpClient to make Moq Testable #1015

Pieeer1 opened this issue Oct 20, 2022 · 3 comments

Comments

@Pieeer1
Copy link

Pieeer1 commented Oct 20, 2022

It would be great if there were more methods from SFTP client in ISftp Client (such as connect) so that in dependency injecting Moq unit tests, you can setup and verify the expressions.

@Pieeer1
Copy link
Author

Pieeer1 commented Oct 20, 2022

Found a couple posts related to this that are closed, however it is still an issue. Current workaround found was:

                if (_sftpClient is SftpClient client)
                {
                    client.Connect();
                }

Where _sftpClient is the interface and your dependency injection looks like:

 builder.Services.AddSingleton<ISftpClient,SftpClient>(
                    (s) => {
                        return new SftpClient("ip", "user", "password");
                    }
                );

Fix found here: #975

@Pieeer1
Copy link
Author

Pieeer1 commented Oct 20, 2022

Additionally, There needs to be an interface for SftpFile, or the class needs to have a more accessible constructor.

@WojciechNagorski
Copy link
Collaborator

ISftpClient has been implemented

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

No branches or pull requests

2 participants