-
Notifications
You must be signed in to change notification settings - Fork 583
Make SendGridClient implement an interface for DI and mocking in tests #403
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
Comments
Hello @Tarball, I'm adding this to our backlog. In the meantime, we are using StopLight.io's Prism along with SendGrid API's OAI specification to create a mock client. The instructions for setting this up locally for testing against a mocked version of the SendGrid API is here: https://github.com/sendgrid/sendgrid-csharp/blob/master/CONTRIBUTING.md#testing (this happens automatically on Travis). With Best Regards, Elmer |
I also want to mock SendGridClient. Thank you! |
Hello @rodchenkov, This PR fixes this issue: #434 It should be merged soon. Thanks! With Best Regards, Elmer |
Actually, this is a different issue. My PR enables the mocking of http responses. The request at hand is for SendGridClient to implement a (new) ISendGridClient interface so that the SendGridClient can be altogether mocked. |
Thanks for clarifying @ottomatic! I've added @rodchenkov's vote to this issue in our backlog. In the mean time @rodchenkov, |
@rodchenkov Please have alook at StrongGrid . It's an alternative .net client for SendGrid'a API which implements an interface for easy mocking. |
Fix issue #403 - implement an interface for mocking and DI
Fixed with #456 |
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
I would like to be able to mock the SendGridClient object so I can unit test my code without actually making any calls to the SendGrid API. Unfortunately the SendGridClient does not implement any interfaces so I have to instantiate it directly instead of being able to use dependency injection to inject the interface.
The old 6.X.X version of the SendGrid client included an ITransport interface which could be mocked for testing without actually hitting the API.
The text was updated successfully, but these errors were encountered: