Isolator AAA: Verification
The syntax makes the tests much more readable. You specify exactly what you expect to have happened.
Verify comes in 3 flavors:
- WasCalledWithExactArguments – The method was called at least once, with the exact parameters specified.
- WasCalledWithAnyArguments – The method was called at least once, regardless of parameters.
- WasNotCalled – Well, you can guess this one.
In future releases, we’re going to add more features around this, like number of times the method was called, more specific checks, and if specific instances got created.
Verify also works great with chains. Have a look at this example:
public void RecursiveStubsWithChainExpectation()
RealLogger fake = Isolate.Fake.Instance<RealLogger>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fake.GetSon().DoSomething(1)).WillReturn(13);
Isolate.Verify.WasCalledWithExactArguments(() => fake.GetSon().DoSomething(10));
Note that the Verify clause checks that the entire chain was called. If only part of it was called, the Verify will fail, and you’ll get a nice VerifyException.
I encourage you to start using these APIs and give us feedback – on readability, coding experience, and fabulous success stories (if they are indeed related to the API).
We are already in the process of implementation of other existing features in the new syntax (first and foremost – static calls), and once they’re out I’ll post on them too. In the meanwhile – go play with these toys.