1 std::shared_ptr<MockThreadRCInvester> spMockaAcc;
2 HelperThreadRCInvester helperAcc;
3
4 // spMockAcc 对象的monitorAccount() 函数被调用时,使用其它的方式来处理
5 // testing::_ 是一个占位符,它表示monitorAccount() 函数的参数个性,每一个代表一个参数。
6 EXPECT_CALL(*spMockAcc, monitorAccount(testing::_, testing::_)).
7 // 期望被调用4 次,如果调用次数不是4 次则会报错。
8 // 如果次数不能控制,则可以直接将此行去掉,则是只要调用都按后面的处理
9 Times(4).
10 // 使用helperAcc 对象中的monitorAccount() 函数替换,但前提是此函数与原函数的返回值和参数一致
11 WillRepeatedly(testing::Invoke(&helperAcc, &HelperThreadRCInvester::monitorAccount));
12
13
14 // 期望每次isMonitor() 函数被调用时都直接返回true.
15 EXPECT_CALL(*spMockAcc, isMonitor()).WillRepeatedly(testing::Return(true));