-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT]: Better mocking support for GitHubClient #129
Comments
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
Hmm...this is a great question. Perhaps it's something that should be filed in the Kiota repo, as our client is generated using the Kiota client. I wonder how they'd recommend mocking and testing. Of course, there's always the idea to introduce a layer of abstraction in your application and mock that, but I wonder what the Kiota team would suggest. |
Makes sense now that you mention it. I've raised a new feature request for this with them now under microsoft/kiota#5560 to continue the discussion there. Thank you! |
Describe the need
I recently had a requirement to mock the GitHubClient that is injected into my service class in order to test the business logic of that class. However, when using Moq, I encountered the message about not being able to mock because of non-overridable members, in this case,
WithRefItemRequestBuilder.GetAsync
. Here is one example under .NET 8:It's a bit verbose due to optional parameters having to be specified, but essentially, the
GetAsync
method, which comes fromGitHub.Repos.Item.Item.Git.MatchingRefs.Item.WithRefItemRequestBuilder
is the culprit. I've also tried instead mocking the adapter since this method callsRequestAdapter.SendCollectionAsync<GitRef>()
under the hood, but either it wasn't working or I did it wrong.My wish is that there be an IGitHubClient or other type of interface that could be used for testing, or make the methods virtual so that they were more test friendly.
SDK Version
octokit/dotnet-sdk v0.0.28
API Version
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: