'L{IReactorTCP.connectTCP} returns an object which provides
L{IConnector}.  The destination of the connector is the address which
was passed to C{connectTCP}.  The same connector object is passed to
the factory\'s C{startedConnecting} method as to the factory\'s
C{clientConnectionLost} method.'

def test_connectorIdentity(self):

    serverFactory = ClosingFactory()
    reactor = self.buildReactor()
    tcpPort = reactor.listenTCP(0, serverFactory, interface=self.interface)
    serverFactory.port = tcpPort
    portNumber = tcpPort.getHost().port
    seenConnectors = []
    seenFailures = []
    clientFactory = ClientStartStopFactory()
    clientFactory.clientConnectionLost = (lambda connector, reason: (seenConnectors.append(connector), seenFailures.append(reason)))
    clientFactory.startedConnecting = seenConnectors.append
    connector = reactor.connectTCP(self.interface, portNumber, clientFactory)
    self.assertTrue(IConnector.providedBy(connector))
    dest = connector.getDestination()
    self.assertEqual(dest.type, 'TCP')
    self.assertEqual(dest.host, self.interface)
    self.assertEqual(dest.port, portNumber)
    clientFactory.whenStopped.addBoth((lambda _: reactor.stop()))
    self.runReactor(reactor)
    seenFailures[0].trap(ConnectionDone)
    self.assertEqual(seenConnectors, [connector, connector])
