'When the reactor passed to ``AgentScript.main`` shuts down, the
service created by the ``service_factory`` is stopped.'

def test_main_stops_service(self):

    service = Service()
    agent = AgentScript(service_factory=(lambda reactor, options: service))
    agent.main(self.reactor, self.options)
    self.reactor.fireSystemEvent('shutdown')
    self.assertFalse(service.running)
