Awesome
<img src="/src/icon.png" height="30px"> Verify.NSubstitute
Adds Verify support for verifying NSubstitute types.
See Milestones for release notes.
NuGet package
https://nuget.org/packages/Verify.NSubstitute/
Usage
<!-- snippet: enable --><a id='snippet-enable'></a>
[ModuleInitializer]
public static void Init() =>
VerifyNSubstitute.Initialize();
<sup><a href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-enable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Given an interface:
<!-- snippet: ITarget.cs --><a id='snippet-ITarget.cs'></a>
public interface ITarget
{
void Method(int a, int b);
}
<sup><a href='/src/Tests/ITarget.cs#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-ITarget.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->It .ReceivedCalls()
can be verified:
<a id='snippet-ReceivedCalls'></a>
[Fact]
public Task Test()
{
var target = Substitute.For<ITarget>();
target.Method(1, 2);
return Verify(target.ReceivedCalls());
}
<sup><a href='/src/Tests/Tests.cs#L5-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-ReceivedCalls' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Will result in:
<!-- snippet: Tests.Test.verified.txt --><a id='snippet-Tests.Test.verified.txt'></a>
[
{
Method: ITarget.Method(int a, int b),
Arguments: [
1,
2
]
}
]
<sup><a href='/src/Tests/Tests.Test.verified.txt#L1-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.Test.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->