在使用 Hippomocks 时,我们很难期望将 byref 参数传递给函数。
class A
{
public:
virtual ~A();
virtual void foo(IBar& callback, const unsigned x);
};
IBar 是一个接口。
然后我有一个函数调用:
void Service::baz()
{a.foo(callback, 1);}
这是测试:
TEST_FIXTURE(PigScalesServiceTest, test_something)
{
A* aMock = mockRepository.Mock<A>();
IBar* callback = mockRepository.Mock<IBar>();
Service service(*amock, *callback);
mockRepository.ExpectCall(aMock, A::foo).With(*callback, 1);
service.baz();
}
运行测试会给我以下错误:
Function A::foo(???,1) called with mismatching expectation!
Expections set:
Expectation for A::foo(???,1) on the mock at 0x0x10969908 was not satisfied.
非常感谢!