更新时间:2023-10-05 14:31:16
答案在文件中总是放置在A.CallTo中的忽略和
The answer is in the docs at Always place Ignored and That inside A.CallTo:
忽略
(和_
)和那个
匹配器必须放在A.CallTo
调用。这是因为这些特殊约束方法不返回实际的匹配器对象。他们告诉FakeItEasy如何通过被触发的特殊事件匹配参数,然后调用约束方法。 FakeItEasy只侦听A.CallTo
的上下文中的事件。
The
Ignored
(and_
) andThat
matchers must be placed within the expression inside theA.CallTo
call. This is because these special constraint methods do not return an actual matcher object. They tell FakeItEasy how to match the parameter via a special event that's fired then the constraint method is invoked. FakeItEasy only listens to the events in the context of anA.CallTo
.
我很惊讶测试失败,但是。你使用什么版本?从FIE 2.0.0开始,使用那个
就像你一样应该抛出一个异常像
I'm surprised the "test fails", though. What version are you using? As of FIE 2.0.0, using That
as you did should throw an exception like
System.InvalidOperationException : A<T>.Ignored, A<T>._, and A<T>.That
can only be used in the context of a call specification with A.CallTo()