Skip to content

Mocking Restease #199

Answered by canton7
aadvark-pancakes asked this question in Q&A
Jul 6, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Your BrandfolderClient constructor does:

_brandFolderApi = RestClient.For<IBrandFolderApi >(url);

So your BrandfolderClient will always use a "real" IBrandFolderApi, and the mock you create in your unit test is unrelated to anything.

This is general programming help unrelated to RestEase, but if you want to test BrandfolderClient, you'll need a way to get it to use a mock IBrandFolderApi, rather than always calling RestClient.For<IBrandFolderApi >(url). That's normally done by having a constructor which accepts an instance of IBrandFolderApi: this might be the only constructor, or you might have one constructor which takes a string, and one which takes a IBrandFolderApi.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aadvark-pancakes
Comment options

Answer selected by aadvark-pancakes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants