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

Asynchronous unit test

parent 1d373493
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import <gRPC/GRPCCall.h>
#import <gRPC/GRPCMethodName.h>
#import <RxLibrary/GRXWriter+Immediate.h>
#import <RxLibrary/GRXWriteable.h>
@interface SampleTests : XCTestCase @interface SampleTests : XCTestCase
@end @end
...@@ -62,4 +67,35 @@ ...@@ -62,4 +67,35 @@
}]; }];
} }
- (void)testConnectionToSandboxServer {
XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.testing"
interface:@"TestService"
method:@"EmptyCall"];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"grpc-test.sandbox.google.com:443"
method:method
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
NSLog(@"Received unexpected response: %@", value);
} completionHandler:^(NSError *errorOrNil) {
if (errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
} else {
[expectation fulfill];
}
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {
if(error) {
XCTFail(@"Server unreachable. Error: %@", error);
}
}];
}
@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