dropbox-sdk-dotnet icon indicating copy to clipboard operation
dropbox-sdk-dotnet copied to clipboard

Inability to mock DropboxClient for unit tests

Open ccelson opened this issue 8 years ago • 2 comments

Would it be possible for the DropboxClient to implement an interface, or do something that would allow for easier mocking with Moq, rather than having to use Fakes or wrap everything? If not do you guys have any suggestions on how I could unit test my services that use the DropboxClient?

ccelson avatar Jun 14 '16 19:06 ccelson

DropboxClient takes in an optional HttpClient object as part of the DropboxClientConfig. So you can create a mocked http client (http://weblogs.asp.net/cibrax/unit-and-integration-testing-with-the-web-api-httpclient) and pass into DropboxClient. As long as you make the mock http client return a valid response json, DropboxClient should still work.

qimingyuan avatar Jun 14 '16 20:06 qimingyuan

@qimingyuan This might cause tests to break if Dropbox format changes and we update to a new library, while actual code won't break (because library hides the specific JSON format).

ashmind avatar Oct 02 '17 04:10 ashmind