def test_implicit_cls_event_registration():
    """Test implicit CLS event registration."""

    with pytest.raises(TypeError):
        ob = EventTest()
        handler = GenericHandler()
        ob.add_PublicEvent(handler.handler)
Пример #2
0
    def test_implicit_cls_event_registration(self):
        """Test implicit CLS event registration."""

        with self.assertRaises(TypeError):
            ob = EventTest()
            handler = GenericHandler()
            ob.add_PublicEvent(handler.handler)
Пример #3
0
    def testExplicitCLSEventRegistration(self):
        """Test explicit CLS event registration."""
        object = EventTest()
        handler = GenericHandler()

        delegate = TestEventHandler(handler.handler)
        object.add_PublicEvent(delegate)
        self.failUnless(handler.value == None)

        object.OnPublicEvent(TestEventArgs(10))        
        self.failUnless(handler.value == 10)

        object.remove_PublicEvent(delegate)
        self.failUnless(handler.value == 10)

        object.OnPublicEvent(TestEventArgs(20))        
        self.failUnless(handler.value == 10)
Пример #4
0
    def testExplicitCLSEventRegistration(self):
        """Test explicit CLS event registration."""
        object = EventTest()
        handler = GenericHandler()

        delegate = TestEventHandler(handler.handler)
        object.add_PublicEvent(delegate)
        self.failUnless(handler.value == None)

        object.OnPublicEvent(TestEventArgs(10))
        self.failUnless(handler.value == 10)

        object.remove_PublicEvent(delegate)
        self.failUnless(handler.value == 10)

        object.OnPublicEvent(TestEventArgs(20))
        self.failUnless(handler.value == 10)
def test_explicit_cls_event_registration():
    """Test explicit CLS event registration."""
    from Python.Test import EventHandlerTest

    ob = EventTest()
    handler = GenericHandler()

    delegate = EventHandlerTest(handler.handler)
    ob.add_PublicEvent(delegate)
    assert handler.value is None

    ob.OnPublicEvent(EventArgsTest(10))
    assert handler.value == 10

    ob.remove_PublicEvent(delegate)
    assert handler.value == 10

    ob.OnPublicEvent(EventArgsTest(20))
    assert handler.value == 10
Пример #6
0
    def test_explicit_cls_event_registration(self):
        """Test explicit CLS event registration."""
        from Python.Test import EventHandlerTest

        ob = EventTest()
        handler = GenericHandler()

        delegate = EventHandlerTest(handler.handler)
        ob.add_PublicEvent(delegate)
        self.assertTrue(handler.value is None)

        ob.OnPublicEvent(EventArgsTest(10))
        self.assertTrue(handler.value == 10)

        ob.remove_PublicEvent(delegate)
        self.assertTrue(handler.value == 10)

        ob.OnPublicEvent(EventArgsTest(20))
        self.assertTrue(handler.value == 10)
Пример #7
0
 def test():
     object = EventTest()
     handler = GenericHandler()
     object.add_PublicEvent(handler.handler)
Пример #8
0
 def test():
     object = EventTest()
     handler = GenericHandler()
     object.add_PublicEvent(handler.handler)