Verify.FakeItEasy/readme.md

2.8 KiB

Verify.FakeItEasy

Discussions Build status NuGet Status

Adds Verify support for verifying FakeItEasy types.

See Milestones for release notes.

NuGet package

https://nuget.org/packages/Verify.FakeItEasy/

Usage

[ModuleInitializer]
public static void Init() =>
    VerifyFakeItEasy.Initialize();

snippet source | anchor

Given an interface:

public interface ITarget
{
    void Method(int a, int b);
}

snippet source | anchor

Its .GetCalls() can be verified:

[Fact]
public Task ReceivedCalls()
{
    var target = A.Fake<ITarget>();
    target.Method(1, 2);
    var calls = Fake.GetCalls(target);
    return Verify(calls);
}

snippet source | anchor

Will result in:

[
  {
    Method: ITarget.Method(int a, int b),
    Arguments: [
      1,
      2
    ]
  }
]

snippet source | anchor

A instance of FakeManager can also be verified.

[Fact]
public Task FakeManager()
{
    var target = A.Fake<ITarget>();
    target.Method(1, 2);
    var fakeManager = Fake.GetFakeManager(target);
    return Verify(fakeManager);
}

snippet source | anchor