Replies: 1 comment
-
I personally would go with mocking. I use NSubstitute and my code looks like this: var apiClient = Substitute.For<IMyApiClient>();
apiClient.ExchangeOauthCode.ExecuteAsync(Arg.Any<OAuthCodeExchangeInput>())
.Returns(new OperationResult<IExchangeOauthCodeResult>(
new ExchangeOauthCodeResult(new ExchangeOauthCode_ExchangeOAuthCode_OAuthCodeExchangeOutput(
null,
new ExchangeOauthCode_ExchangeOAuthCode_AccessToken_AccessToken(600, "the-access-token", "Bearer", null),
null)
),
null,
null!,
null)
); Not super readable, unfortunately. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a service that consumes a GraphQL client generated by Strawberry Shake. I want to write some unit tests for this service. How can I do that?
I see 3 ways:
StrawberryShake.Transport.InMemory
Based on this SO question, I have a feeling that option 3 is the answer, but I'm unable to make it work. I also didn't find any examples on how to use In Memory transport. Source code and tests provided little help.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions