Exemplo n.º 1
0
 async def test_dispatch_sync(self):
     Mediator.register_handler(get_array_handler_sync)
     Mediator.register_handler(GetArrayQueryHandler)
     Mediator.register_behavior(common_log_behavior)
     mediator = Mediator()
     query1 = GetArrayQuery(5)
     result1 = mediator.send(query1)
     self.assertEqual(len(result1), 5)
     self.assertIsNotNone(query1.updated_at)
     query2 = GetArrayQuery1(4)
     result2 = mediator.send(query2)
     self.assertEqual(len(result2), 4)
     self.assertIsNotNone(query2.updated_at)
Exemplo n.º 2
0
    def test_first(self):
        mediator = Mediator()
        Mediator.register_handler(QueryWithTypedResponseHandler)

        genericQuery = QueryWithTypedResponse(name="mediatr 123")
        respModel = mediator.send(genericQuery)
        self.assertEqual(genericQuery.some_name, respModel.some_name)
Exemplo n.º 3
0
 def test_dispatch_sync_without_behavior(self):
     Mediator.register_handler(get_array_handler_sync)
     Mediator.register_handler(GetArrayQueryHandler)
     mediator = Mediator()
     query1 = GetArrayQuery(5)
     result1 = mediator.send(query1)
     self.assertEqual(len(result1), 5)
Exemplo n.º 4
0
    def test_first(self):

        Mediator.register_handler(get_array_handler_sync)
        Mediator.register_handler(GetArrayQueryHandler)
        Mediator.register_handler(QueryWithTypedResponseHandler)
        Mediator.register_behavior(common_log_behavior)
        Mediator.register_behavior(print_before)

        query1 = GetArrayQuery(5)
        result1 = Mediator.send(query1)
        self.assertEqual(len(result1), 5)
        self.assertIsNotNone(query1.updated_at)
        query2 = GetArrayQuery1(4)
        result2 = Mediator.send(query2)
        self.assertEqual(len(result2), 4)
        self.assertIsNotNone(query2.updated_at)
        self.assertEqual(query1.updated_at, '123')
        self.assertEqual(query2.updated_at, '123')
        self.assertTrue(query2.common_bahavior_handled)