diff options
Diffstat (limited to 'SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m')
-rw-r--r-- | SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m b/SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m index 24d4943c1..808ba33bf 100644 --- a/SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m +++ b/SmartDeviceLinkTests/TransportSpecs/iAP/SDLIAPTransportSpec.m @@ -42,7 +42,7 @@ describe(@"SDLIAPTransport", ^{ __block EAAccessory *mockAccessory = nil; beforeEach(^{ - transport = [SDLIAPTransport new]; + transport = [[SDLIAPTransport alloc] init]; mockTransportDelegate = OCMProtocolMock(@protocol(SDLTransportDelegate)); transport.delegate = mockTransportDelegate; mockAccessory = [EAAccessory.class sdlCoreMock]; @@ -142,26 +142,22 @@ describe(@"SDLIAPTransport", ^{ __block SDLIAPDataSession *mockDataSession = nil; beforeEach(^{ - mockDataSession = OCMClassMock([SDLIAPDataSession class]); + mockDataSession = OCMStrictClassMock([SDLIAPDataSession class]); OCMStub([mockDataSession isSessionInProgress]).andReturn(YES); OCMStub([mockDataSession connectionID]).andReturn(mockAccessory.connectionID); transport.dataSession = mockDataSession; transport.controlSession = nil; - - [[NSNotificationCenter defaultCenter] postNotification:accessoryDisconnectedNotification]; }); - it(@"It should cleanup on disconnect", ^{ - expect(transport.retryCounter).to(equal(0)); - expect(transport.sessionSetupInProgress).to(beFalse()); - expect(transport.transportDestroyed).to(beTrue()); - }); + it(@"It should cleanup on disconnect, close and destroy data session, and notify the lifecycle manager that the transport disconnected", ^{ + OCMExpect([mockDataSession destroySessionWithCompletionHandler:[OCMArg invokeBlock]]); - it(@"It should close and destroy data session", ^{ - OCMVerify([mockDataSession destroySession]); - }); + [[NSNotificationCenter defaultCenter] postNotification:accessoryDisconnectedNotification]; + + expect(transport.retryCounter).toEventually(equal(0)); + expect(transport.sessionSetupInProgress).toEventually(beFalse()); + expect(transport.transportDestroyed).toEventually(beTrue()); - it(@"It should notify the lifecycle manager that the transport disconnected ", ^{ OCMVerify([mockTransportDelegate onTransportDisconnected]); }); }); @@ -170,26 +166,22 @@ describe(@"SDLIAPTransport", ^{ __block SDLIAPControlSession *mockControlSession = nil; beforeEach(^{ - mockControlSession = OCMClassMock([SDLIAPControlSession class]); + mockControlSession = OCMStrictClassMock([SDLIAPControlSession class]); OCMStub([mockControlSession isSessionInProgress]).andReturn(YES); OCMStub([mockControlSession connectionID]).andReturn(mockAccessory.connectionID); transport.controlSession = mockControlSession; transport.dataSession = nil; - - [[NSNotificationCenter defaultCenter] postNotification:accessoryDisconnectedNotification]; }); - it(@"It should cleanup on disconnect", ^{ - expect(transport.retryCounter).to(equal(0)); - expect(transport.sessionSetupInProgress).to(beFalse()); - expect(transport.transportDestroyed).to(beFalse()); - }); + it(@"It should cleanup on disconnect, close and destroy data session, and should not tell the delegate that the transport closed", ^{ + OCMExpect([mockControlSession destroySessionWithCompletionHandler:[OCMArg invokeBlock]]); - it(@"It should close and destroy data session", ^{ - OCMVerify([mockControlSession destroySession]); - }); + [[NSNotificationCenter defaultCenter] postNotification:accessoryDisconnectedNotification]; + + expect(transport.retryCounter).toEventually(equal(0)); + expect(transport.sessionSetupInProgress).toEventually(beFalse()); + expect(transport.transportDestroyed).toEventually(beFalse()); - it(@"Should not tell the delegate that the transport closed", ^{ OCMReject([mockTransportDelegate onTransportDisconnected]); }); }); |