'C{endpoints.connectProtocol} calls the given endpoint\'s C{connect()}
method with a factory that will build the given protocol.'

def test_connectProtocolCreatesFactory(self):

    reactor = MemoryReactor()
    endpoint = endpoints.TCP4ClientEndpoint(reactor, '127.0.0.1', 0)
    theProtocol = object()
    endpoints.connectProtocol(endpoint, theProtocol)
    self.assertEqual(len(reactor.tcpClients), 1)
    factory = reactor.tcpClients[0][2]._wrappedFactory
    self.assertIsInstance(factory, protocol.Factory)
    self.assertIs(factory.buildProtocol(None), theProtocol)
