如何设置对模拟的特定调用?

How to setup specific call to for mocks?

我正在使用 FakeItEasy 来模拟单元测试中的内容,但不知何故我无法设置 非常基本的场景。 IE。我想在特定用户访问方法时抛出异常。帮助会很好...谢谢

A.CallTo(() => m_fancyRepository
                .CanIDoFancyThings(A<User>
                    .That
                    .Matches(u => u.Id.Equals(m_user.Id)))
                .Verify())
                .Throws(new Exception("omg !!! ???!"));

尝试去掉存根后的Verify()方法,像这样:

A.CallTo(() => m_fancyRepository.CanIDoFancyThings(
            A<User>.That.Matches(u => u.Id.Equals(m_user.Id))))
            .Throws(new Exception("omg !!! ???!"));