|
|
|
@ -38,7 +38,7 @@ |
|
|
|
|
#import <gRPC/GRPCMethodName.h> |
|
|
|
|
#import <gRPC/GRXWriter+Immediate.h> |
|
|
|
|
#import <gRPC/GRXWriteable.h> |
|
|
|
|
#import <Route_guide/Route_guide.pb.h> |
|
|
|
|
#import <Route_guide/RouteGuide.pbobjc.h> |
|
|
|
|
|
|
|
|
|
@interface SampleTests : XCTestCase |
|
|
|
|
@end |
|
|
|
@ -105,15 +105,15 @@ |
|
|
|
|
|
|
|
|
|
- (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:-15E7] build]; |
|
|
|
|
RGDPoint *point = [RGDPoint message]; |
|
|
|
|
point.latitude = 28E7; |
|
|
|
|
point.longitude = -15E7; |
|
|
|
|
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]]; |
|
|
|
|
|
|
|
|
|
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" |
|
|
|
@ -122,11 +122,10 @@ |
|
|
|
|
|
|
|
|
|
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { |
|
|
|
|
XCTAssertNotNil(value, @"nil value received as response."); |
|
|
|
|
[response fulfill]; |
|
|
|
|
RGDFeature *feature = [RGDFeature parseFromData:value]; |
|
|
|
|
XCTAssertEqualObjects(point, feature.location); |
|
|
|
|
XCTAssertNotNil(feature.name, @"Response's name is nil."); |
|
|
|
|
[expectedResponse fulfill]; |
|
|
|
|
[response fulfill]; |
|
|
|
|
} completionHandler:^(NSError *errorOrNil) { |
|
|
|
|
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil); |
|
|
|
|
[completion fulfill]; |
|
|
|
|