Using FakeItEasy, I have a setup similar to the one below in one of my tests, and the CallTo
assertion at the bottom is failing when setup like this.
var fakedTool = A.Fake<ITool>();
var concreteUnderTest = new Concrete(fakedTool);
concreteUnderTest.doSomething();
var fooConstraint = A<Foo>.That.Matches(f => f.Name.Equals('Alice'));
var barConstraint = A<Bar>.Ignored;
A.CallTo(() => fakedTool.ObservedFunction(fooConstraint , barConstraint))
.MustHaveHappened(Repeated.Exactly.Once);
I have placed a breakpoint directly above the CallTo
line, and the values of fooConstraint
and barConstraint
are both null
.
When I set the assertion up like this, however, it passes:
A.CallTo(() =>
fakedTool.ObservedFunction(
A<Foo>.That.Matches(f => f.Name.Equals('Alice')),
A<Bar>.Ignored
)
).MustHaveHappened(Repeated.Exactly.Once);
What is causing this behaviour? Is it intended?
This is intended behaviour. You can see the section Always place Ignored
and That
inside A.CallTo
in the docs.
As of FakeItEasy 2.0.0, FakeItEasy will throw an exception when they're stored as variables and invoked , rather than failing quietly by being null.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.