Moq
Moq is intended to be simple to use, strongly typed (no magic strings!, and therefore full compiler-verified and refactoring-friendly) and minimalistic (while still fully functional!).
1 | using Moq; |
If the method being mocked (SelectList
) has parameters you don’t care about then you can mock them with It.IsAny
1 | It.IsAny<string>() |
- See Unit testing with NUnit
- https://github.com/Moq/moq4/wiki/Quickstart
- https://developerhandbook.com/unit-testing/writing-unit-tests-with-nunit-and-moq/
- http://www.aamiraftab.com/unit-testing-repository-pattern-using-moq-shouldly-in-xunit-framework/
- https://www.codeproject.com/Articles/47603/Mock-a-Database-Repository-using-Moq
- https://www.pluralsight.com/courses/aspdotnet-core-mvc-testing-fundamentals
- https://www.pluralsight.com/courses/mocking-with-moq
Others
- NSubstitute
- Rhino Mocks
- Type Mock