You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 from GitHub.Repos.Item.Item.Git.MatchingRefs.Item.WithRefItemRequestBuilder is the culprit. I've also tried instead mocking the adapter since this method calls RequestAdapter.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
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
👋 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 Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀
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.
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: