Skip to content

Commit

Permalink
removed the extra tests for the basic connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jdiehl committed Aug 26, 2015
1 parent 317d5a1 commit 728cf90
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions Tests/Shared/GCDAsyncSocketConnectionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ @interface GCDAsyncSocketConnectionTests : XCTestCase <GCDAsyncSocketDelegate>
@property (nonatomic, strong) GCDAsyncSocket *clientSocket;
@property (nonatomic, strong) GCDAsyncSocket *serverSocket;
@property (nonatomic, strong) GCDAsyncSocket *acceptedServerSocket;
@property (nonatomic, strong) NSData *readData;

@property (nonatomic, strong) XCTestExpectation *expectation;
@end
Expand Down Expand Up @@ -57,60 +56,6 @@ - (void)testFullConnection {
}];
}

- (void)testTransferFromClient {

NSData *testData = [@"ThisTestRocks!!!" dataUsingEncoding:NSUTF8StringEncoding];

// set up and conncet to socket
[self.serverSocket acceptOnPort:kTestPort error:nil];
[self.clientSocket connectToHost:@"127.0.0.1" onPort:kTestPort error:nil];

// wait for connection
self.expectation = [self expectationWithDescription:@"Socket Connected"];
[self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {

// start reading
[self.acceptedServerSocket readDataWithTimeout:-1 tag:0];

// send data
self.expectation = [self expectationWithDescription:@"Data Sent"];
[self.clientSocket writeData:testData withTimeout:-1 tag:0];
[self waitForExpectationsWithTimeout:1 handler:^(NSError *error) {
if (error) {
return NSLog(@"Error reading data");
}
XCTAssertTrue([testData isEqual:self.readData], @"Read data did not match test data");
}];
}];
}

- (void)testTransferFromServer {

NSData *testData = [@"ThisTestRocks!!!" dataUsingEncoding:NSUTF8StringEncoding];

// set up and conncet to socket
[self.serverSocket acceptOnPort:kTestPort error:nil];
[self.clientSocket connectToHost:@"127.0.0.1" onPort:kTestPort error:nil];

// wait for connection
self.expectation = [self expectationWithDescription:@"Socket Connected"];
[self waitForExpectationsWithTimeout:30 handler:^(NSError *error) {

// start reading
[self.clientSocket readDataWithTimeout:-1 tag:0];

// send data
self.expectation = [self expectationWithDescription:@"Data Sent"];
[self.acceptedServerSocket writeData:testData withTimeout:-1 tag:0];
[self waitForExpectationsWithTimeout:1 handler:^(NSError *error) {
if (error) {
return NSLog(@"Error reading data");
}
XCTAssertTrue([testData isEqual:self.readData], @"Read data did not match test data");
}];
}];
}

#pragma mark GCDAsyncSocketDelegate methods

/**
Expand All @@ -137,21 +82,5 @@ - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(ui
[self.expectation fulfill];
}

/**
* Called when a socket has completed reading the requested data into memory.
* Not called if there is an error.
**/
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
NSLog(@"didReadData: %@ withTag: %ld", data, tag);
self.readData = data;
[self.expectation fulfill];
}

- (void)socketDidDisconnect:(GCDAsyncSocket *)socket withError:(NSError *)error;
{
NSLog(@"[Server] Closed connection: %@", error);
}



@end

0 comments on commit 728cf90

Please sign in to comment.