Skip to content
Snippets Groups Projects
Commit 6a84b3d2 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Adds test that sends proto and expects one

parent aa5611be
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#import <gRPC/GRPCMethodName.h> #import <gRPC/GRPCMethodName.h>
#import <gRPC/GRXWriter+Immediate.h> #import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/GRXWriteable.h> #import <gRPC/GRXWriteable.h>
#import <Route_guide/Route_guide.pb.h>
@interface SampleTests : XCTestCase @interface SampleTests : XCTestCase
@end @end
...@@ -101,4 +102,37 @@ ...@@ -101,4 +102,37 @@
[self waitForExpectationsWithTimeout:2.0 handler:nil]; [self waitForExpectationsWithTimeout:2.0 handler:nil];
} }
- (void)testSimpleProtoRPC {
__weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."];
__weak XCTestExpectation *expectedResponse =
[self expectationWithDescription:@"Expected response."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide"
interface:@"RouteGuide"
method:@"GetFeature"];
RGDPoint *point = [[[[[RGDPointBuilder alloc] init] setLatitude:28E7] setLongitude:-30E7] build];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"127.0.0.1:8980"
method:method
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
[response fulfill];
RGDFeature *feature = [RGDFeature parseFromData:value];
NSLog(@"%@ %@", feature.name, feature.location);
[expectedResponse fulfill];
} completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2.0 handler:nil];
}
@end @end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment