NSubstitute
A .NET library that creates test doubles for interfaces with readable syntax, such as Substitute.For<IProductRepository>().
In more detail
Configure a return value with .Returns(...) and check a call with .Received(). Assert collaborations only when they are part of the contract.
Related terms
- test double — Any object that replaces a real dependency in a test: a stub returns canned data, a fake is a small working implementation, and a mock checks interactions.
- mock — A test double that stands in for a real dependency and checks that the code under test calls it in the expected way.
- unit test — An automated check of one small piece of code, such as a single function, that runs quickly and on its own.
Taught in
- Unit Testing with xUnit and NSubstitute — Modern .NET Core, C# & Enterprise Microservices