Beispiel #1
0
    def test_reverse_mediator(self):
        mediator = FunctionalMediator(lambda value: value + 100,
                                      lambda value: value - 100)
        reverse_mediator = mediator.reverse()

        self.assertEqual(
            mediator.forward_value(reverse_mediator.forward_value(77)), 77)
        self.assertEqual(mediator.back_value(reverse_mediator.back_value(77)),
                         77)

        self.assertEqual(
            mediator.forward_value(reverse_mediator.back_value(33)), 233)
        self.assertEqual(
            mediator.back_value(reverse_mediator.forward_value(33)), -167)

        self.assertEqual(
            mediator.forward(reverse_mediator.forward(wrap_argument))(77),
            (77, ))
        self.assertEqual(
            mediator.back(reverse_mediator.back(wrap_argument))(77), (77, ))

        self.assertEqual(
            mediator.forward(reverse_mediator.back(wrap_argument))(33),
            (233, ))
        self.assertEqual(
            mediator.back(reverse_mediator.forward(wrap_argument))(33),
            (-167, ))
Beispiel #2
0
    def test_reverse_mediator (self):
        mediator         = FunctionalMediator (lambda value: value + 100,
                                               lambda value: value - 100)
        reverse_mediator = mediator.reverse ()

        self.assertEqual (mediator.forward_value (reverse_mediator.forward_value (77)), 77)
        self.assertEqual (mediator.back_value    (reverse_mediator.back_value    (77)), 77)

        self.assertEqual (mediator.forward_value (reverse_mediator.back_value    (33)), 233)
        self.assertEqual (mediator.back_value    (reverse_mediator.forward_value (33)), -167)

        self.assertEqual (mediator.forward (reverse_mediator.forward (wrap_argument)) (77), (77,))
        self.assertEqual (mediator.back    (reverse_mediator.back    (wrap_argument)) (77), (77,))

        self.assertEqual (mediator.forward (reverse_mediator.back    (wrap_argument)) (33), (233,))
        self.assertEqual (mediator.back    (reverse_mediator.forward (wrap_argument)) (33), (-167,))
Beispiel #3
0
    def test_functional_mediator (self):
        mediator = FunctionalMediator (lambda value: value + 100, lambda value: value - 100)

        self.assertEqual (mediator.forward_value (15), 115)
        self.assertEqual (mediator.back_value    (15), -85)

        self.assertEqual (mediator.forward (wrap_argument) (15), (115,))
        self.assertEqual (mediator.back    (wrap_argument) (15), (-85,))
Beispiel #4
0
    def test_functional_mediator(self):
        mediator = FunctionalMediator(lambda value: value + 100,
                                      lambda value: value - 100)

        self.assertEqual(mediator.forward_value(15), 115)
        self.assertEqual(mediator.back_value(15), -85)

        self.assertEqual(mediator.forward(wrap_argument)(15), (115, ))
        self.assertEqual(mediator.back(wrap_argument)(15), (-85, ))
Beispiel #5
0
    def test_double_reverse_mediator (self):
        mediator1 = FunctionalMediator (lambda value: value + 100, lambda value: value - 100)
        mediator2 = mediator1.reverse ().reverse ()

        self.assertEqual (mediator1.forward_value (10), mediator2.forward_value (10))
        self.assertEqual (mediator1.back_value    (10), mediator2.back_value    (10))

        self.assertEqual (mediator1.forward (wrap_argument) (10),
                          mediator2.forward (wrap_argument) (10))
        self.assertEqual (mediator1.back    (wrap_argument) (10),
                          mediator2.back    (wrap_argument) (10))
Beispiel #6
0
    def test_double_reverse_mediator(self):
        mediator1 = FunctionalMediator(lambda value: value + 100,
                                       lambda value: value - 100)
        mediator2 = mediator1.reverse().reverse()

        self.assertEqual(mediator1.forward_value(10),
                         mediator2.forward_value(10))
        self.assertEqual(mediator1.back_value(10), mediator2.back_value(10))

        self.assertEqual(
            mediator1.forward(wrap_argument)(10),
            mediator2.forward(wrap_argument)(10))
        self.assertEqual(
            mediator1.back(wrap_argument)(10),
            mediator2.back(wrap_argument)(10))