I have used SSH.Net's SftpClient object to perform upload and dowload operations on the server.
I am trying to write unit test cases for the class that uses this SftpClient object.
The class itself is mocked but I am unable to setup a client object without actually having to connect to the server, which is not right.
public class MockFTPStreamRepository : IFTPStreamRepository
{
public async Task<MySFTFReposResults> MyMethod1(MyDTO dto)
{
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
SftpClient myClient = new SftpClient("ftp://localhost", "", "");
sftpClient.Connect();
writer.Write("Some Content");
writer.Flush();
stream.Position = 0;
return new MySFTFReposResults { IsTransferSuccess = true, FileStream = stream, sftpClient = myClient};
}
}
I cannot give an actual ftp server and credentials above to connect as that wont hold for other environments.
Is there a way to get a valid SftpClient object from this ?