'A client endpoint can connect and returns a deferred who gets called
back with a protocol instance.'

def test_endpointConnectSuccess(self):

    proto = object()
    mreactor = MemoryReactor()
    clientFactory = object()
    (ep, expectedArgs, ignoredDest) = self.createClientEndpoint(mreactor, clientFactory)
    d = ep.connect(clientFactory)
    receivedProtos = []
    def checkProto(p):
        receivedProtos.append(p)
    d.addCallback(checkProto)
    factory = self.retrieveConnectedFactory(mreactor)
    factory._onConnection.callback(proto)
    self.assertEqual(receivedProtos, [proto])
    expectedClients = self.expectedClients(mreactor)
    self.assertEqual(len(expectedClients), 1)
    self.assertConnectArgs(expectedClients[0], expectedArgs)
