Skip to content
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

Mocking support for APIs #172

Open
luixodev opened this issue Sep 22, 2022 · 1 comment
Open

Mocking support for APIs #172

luixodev opened this issue Sep 22, 2022 · 1 comment

Comments

@luixodev
Copy link

Hello,
I'm trying to unit test my solution using Moq framework, but since Moq cannot mock non-virtual type members I always get an Unsupported Error Type. Is there any work around for Mock MangoPayApi services and the apis within ?

I found a couple of possible solutions.
One could be making the class virtual (devlooped/moq#961)
The other one is to create interfaces for this api classes

Thank you

@juangcarmona
Copy link

Hi,

I created a dot net core library some years ago, before Mangopay released the mangopay2-net-sdk.
I based my work on their previous library, which targeted old .NET framework, I had to do some refactoring to apply best practices and, in my project, you can find I used interfaces, exactly for that reason (unit test with mocking and moq). In the docs, you can find that you can easily do basic mocking...

BTW, at that point (using that library on prod) I sent the code to Mangopay, but nobody answered, that's why I published it here in GitHub.

https://github.com/jgcarmona-com/mangopay-net-core-sdk

I hope it helps you. At least you have an alternative if it fits your needs.

Juan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants