Added server_streaming interop test

pull/1626/head
murgatroid99 10 years ago
parent e195aa0ef7
commit ea43b903a3
  1. 34
      src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m

@ -69,7 +69,7 @@
} }
- (void)testLargeUnaryRPC { - (void)testLargeUnaryRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init] RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
setResponseType:RMTPayloadTypeCompressable] setResponseType:RMTPayloadTypeCompressable]
@ -95,7 +95,7 @@
} }
- (void)testClientStreamingRPC { - (void)testClientStreamingRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init] id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
setPayloadBuilder:[[[RMTPayloadBuilder alloc] init] setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
@ -130,4 +130,34 @@
[self waitForExpectationsWithTimeout:4. handler:nil]; [self waitForExpectationsWithTimeout:4. handler:nil];
} }
- (void)testServerStreamingRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"];
NSArray *expectedSizes = @[@31415, @9, @2653, @58979];
int index = 0;
id request = [[[[[[[RMTStreamingOutputCallRequestBuilder alloc] init]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:31415] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:9] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:2653] build]]
addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
setSize:58979] build]]
build];
[_service streamingOutputCallWithRequest:request handler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
id expectedResponseBuilder = [[RMTStreamingOutputCallResponseBuilder alloc] init];
id expectedPayload = [[[RMTPayloadBuilder alloc] init]
setBody:[NSMutableData dataWithLength:expectedSizes[index]]];
expectedResponseBuilder = [expectedResponseBuilder setPayload:expectedPayload];
id expectedResponse = [expectedResponseBuilder build];
XCTAssertEqualObjects(response, expectedResponse);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:4 handler:nil];
}
@end @end

Loading…
Cancel
Save