I have always been using Moq for mocking external dependencies while unit testing. Now that I am trying to make my code completely cross platform, I want to make my unit tests run on linux too and so I am targeting my project coreclr50.
The issue is I can't seem to find any mocking libraries that would enable me to mock on coreclr. LightMock.vNext has attempted to do it, but it requires creating mock classes manually which is not convenient.
I wonder how are people unit testing their MVC 6 controllers!
The ASP.NET team seems to be using Moq https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNet.Mvc.Core.Test/project.json:
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
NSubstitute is a great mocking framework. As far as I can see they don't directly support coreclr yet, but they have a pull request on GitHub for that:
https://github.com/nsubstitute/NSubstitute/pull/197
So you can try to do it yourself or wait a bit. Moq was a good framework, but as far as I remember it's not maintained for a long time now. NSubstitute has nicer syntax as well (at least IMHO :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With