Any suggestions for how to include FluentFTP in unit test mocks?
I am attempting to add some unit tests for out application and I would like to mock either .Connect(); or .IsConnected however neither of these are mockable due to non-overrideable members. I was wondering if you had any suggestions to get around this?
I'd like @robinrodricks to chime in on this one. But I think that something could be done to make this possible.
Can you provide the members that you need overridable for your mockery?
Hi. If possible, .Connect(), .DisConnect(), and .IsConnected. However I could probably achieve what I need to without .DisConnect() as I could use .IsConnected instead.
@nathanjwtx I have committed some fake FTP clients suitable for mocking. Please check it and get back if it fulfills your use case
https://www.nuget.org/packages/FluentFTP/53.0.1
Sorry for the delayed response. Going to take a look at this today.
Not sure if perhaps I'm dong something incorrectly but the following code responds with the same error regarding non-overridable members not allowed in setup.
var mockFtp = new Mock<FakeAsyncFtpClient>();
mockFtp.Setup(x => x.IsAuthenticated).Returns(true);
mockFtp.Setup(x => x.IsConnected).Returns(true);
I don't understand. What's the error and how do you expect us to fix it? Pls take a look at the class code and suggest a fix.
https://github.com/robinrodricks/FluentFTP/tree/master/FluentFTP/Client/FakeClient
Thank you for your time and updates. I think this issue can be closed now as I have been able to achieve what I was looking to do.