2.3 KiB
2.3 KiB
Verify.Moq
Adds Verify support for verifying Moq types.
See Milestones for release notes.
NuGet package
https://nuget.org/packages/Verify.Moq/
Usage
[ModuleInitializer]
public static void Init() =>
VerifyMoq.Initialize();
Given an interface:
public interface ITarget
{
string Method(int a, int b);
}
The Mock and its invocations can then be verified:
[Fact]
public Task Test()
{
var mock = new Mock<ITarget>();
mock.Setup(_ => _.Method(It.IsAny<int>(), It.IsAny<int>()))
.Returns("response");
var target = mock.Object;
target.Method(1, 2);
return Verify(mock);
}
Will result in:
[
{
Method: ITarget.Method(int a, int b),
Arguments: [
1,
2
],
ReturnValue: response
}
]