'L{ClientService.whenConnected} returns a L{Deferred} that
errbacks with L{CancelledError} if
L{ClientService.stopService} is called between connection
attempts.'

def test_whenConnectedErrbacksOnStopService(self):

    clock = Clock()
    (cq, service) = self.makeReconnector(fireImmediately=False, clock=clock)
    beforeErrbackAndStop = service.whenConnected()
    cq.connectQueue[0].errback(Exception('no    connection'))
    service.stopService()
    afterErrbackAndStop = service.whenConnected()
    self.assertIsInstance(self.failureResultOf(beforeErrbackAndStop).value, CancelledError)
    self.assertIsInstance(self.failureResultOf(afterErrbackAndStop).value, CancelledError)
