NSubstitute 6.0.0-rc.1
NSubstitute
A friendly substitute for .NET mocking libraries.
Perfect for those new to testing, and for others who would just like to to get their tests written with less noise and fewer lambdas.
How to use
// Create:
var calculator = Substitute.For<ICalculator>();
// Set a return value:
calculator.Add(1, 2).Returns(3);
Assert.AreEqual(3, calculator.Add(1, 2));
// Check received calls:
calculator.Received().Add(1, Arg.Any<int>());
calculator.DidNotReceive().Add(2, 2);
// Raise events
calculator.PoweringUp += Raise.Event();
Optional Roslyn analysers
- For C# projects: NSubstitute.Analyzers.CSharp
- For VB projects: NSubstitute.Analyzers.VisualBasic
Getting help
If you have questions, feature requests or feedback on NSubstitute please raise an issue on our project site.
More information
- Visit NSubstitute website for more examples and documentation.
- Visit NSubstitute on GitHub.
Showing the top 20 packages that depend on NSubstitute.
| Packages | Downloads |
|---|---|
|
AutoFixture.AutoNSubstitute
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by NSubstitute. To use it, add the AutoNSubstituteCustomization to your Fixture instance.
|
11 |
|
AutoFixture.AutoNSubstitute
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by NSubstitute. To use it, add the AutoNSubstituteCustomization to your Fixture instance.
|
10 |
|
AutoFixture.AutoNSubstitute
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by NSubstitute. To use it, add the AutoNSubstituteCustomization to your Fixture instance. Read more at http://autofixture.codeplex.com/
|
10 |
|
AutoFixture.AutoNSubstitute
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by NSubstitute. To use it, add the AutoNSubstituteCustomization to your Fixture instance. Read more at http://autofixture.codeplex.com/
|
9 |
|
AutoFixture.AutoNSubstitute
This extension turns AutoFixture into an Auto-Mocking Container. The mock instances are created by NSubstitute. To use it, add the AutoNSubstituteCustomization to your Fixture instance.
|
9 |
.NET 8.0
- Castle.Core (>= 5.1.1)
.NET Standard 2.0
- Castle.Core (>= 5.1.1)
- System.Threading.Tasks.Extensions (>= 4.5.4)
| Version | Downloads | Last updated |
|---|---|---|
| 6.0.0-rc.1 | 1 | 3/22/2026 |
| 5.3.0 | 10 | 3/20/2025 |
| 5.1.0 | 10 | 3/20/2025 |
| 5.0.0 | 10 | 3/20/2025 |
| 4.4.0 | 6 | 3/20/2025 |
| 4.3.0 | 10 | 3/20/2025 |
| 4.2.2 | 10 | 3/20/2025 |
| 4.2.1 | 10 | 3/20/2025 |
| 4.2.0 | 10 | 3/20/2025 |
| 4.1.0 | 10 | 3/20/2025 |
| 4.0.0 | 10 | 3/20/2025 |
| 3.1.0 | 10 | 3/20/2025 |
| 3.0.1 | 10 | 3/20/2025 |
| 2.0.3 | 8 | 3/20/2025 |
| 1.10.0 | 10 | 3/20/2025 |
| 1.9.2 | 10 | 3/20/2025 |
| 1.9.1 | 10 | 3/20/2025 |
| 1.8.2 | 10 | 3/20/2025 |
| 1.8.1 | 10 | 3/20/2025 |
| 1.8.0 | 10 | 3/20/2025 |
| 1.7.2 | 10 | 3/20/2025 |
| 1.7.1 | 10 | 3/20/2025 |
| 1.7.0 | 10 | 3/20/2025 |
| 1.6.1 | 10 | 3/20/2025 |
| 1.6.0 | 10 | 3/20/2025 |
| 1.5.0 | 10 | 3/20/2025 |
| 1.4.3 | 10 | 3/20/2025 |
| 1.4.2 | 10 | 3/20/2025 |
| 1.4.1 | 10 | 3/20/2025 |
| 1.4.0 | 10 | 3/20/2025 |
| 1.3.0 | 10 | 3/20/2025 |
| 1.2.1 | 10 | 3/20/2025 |
| 1.2.0 | 10 | 3/20/2025 |
| 1.1.0 | 10 | 3/20/2025 |
| 1.0.0 | 10 | 3/20/2025 |