Mocking the SftpClient

Feb 25, 2015 at 9:30 AM
I'm trying to write unit tests for my application which uses the SftpClient class and I want to inject a mock (using Moq) of the SftpClient object, however I'm really struggling to manage this. I was wondering if anyone else had managed to do this without writing a wrapper class.

My code looks like:
             var _connectionInfo = new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "pwd"));
            _sftpClient = new Mock<SftpClient>(_connectionInfo);
            _sftpClient.Setup(m => m.Connect());
but when I try and setup the Connect method I get the error "Invalid setup on a non-virtual"

Has anyone managed to successfully do this, I'm sure I must be missing something!