I want to test client and thus mocking server by gmock. My proto is defined as
// The greeting service definition.
service Greeter {
// Streaming request and reply
rpc StreamRequestAndReply (stream Request) returns (stream Reply) {}
}
message Request {
int32 idx = 1;
bool is_pause = 2; // control message
}
message Reply {
string msg = 1;
bool is_eof = 2;
}
And the correspinding function on server-side looks like
Status StreamRequestAndReply(ServerContext *context, ServerReaderWriter<Reply, Request> *stream) override {
// do something
}
My question is: how to write my predefined Reply message via the mocked stub by gmock, for example I want to reply three valid message and then set is_eof in the fourth one?
My current thinking is using testing::Invoke, but haven't figured out how to capture the stream and call the Write function. Can someone give me some suggestions and hints?