aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/examples/Sample/SampleTests
diff options
context:
space:
mode:
Diffstat (limited to 'src/objective-c/examples/Sample/SampleTests')
-rw-r--r--src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
index 2ef6a6e4ab..322d86d04b 100644
--- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+++ b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
@@ -69,7 +69,7 @@
}
- (void)testLargeUnaryRPC {
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
setResponseType:RMTPayloadTypeCompressable]
@@ -95,7 +95,7 @@
}
- (void)testClientStreamingRPC {
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
@@ -130,4 +130,34 @@
[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