'Test that the transport can set the running service and dispatches
packets to the service\'s packetReceived method.'

def test_service(self):

    service = MockService()
    self.proto.setService(service)
    self.assertEqual(self.proto.service, service)
    self.assertTrue(service.started)
    self.proto.dispatchMessage(255, 'test')
    self.assertEqual(self.packets, [(255, 'test')])
    service2 = MockService()
    self.proto.setService(service2)
    self.assertTrue(service2.started)
    self.assertTrue(service.stopped)
    self.proto.connectionLost(None)
    self.assertTrue(service2.stopped)
