public void AutoEventConnector_TestConnectDisconnect()
        {
            var testEventPublisher = new TestEventPublisher();
            var testEventSubscriber = new TestEventSubscriber();

            testEventSubscriber.ConnectTo(testEventPublisher);

            testEventPublisher.RaiseTestEvent1();
            testEventPublisher.RaiseTestEvent2();
            Assert.AreEqual(0, testEventSubscriber.HandleTestEvent1Count);
            Assert.AreEqual(1, testEventSubscriber.HandleTestEventPublisherTestEvent1Count);

            testEventSubscriber.DisconnectFrom(testEventPublisher);

            testEventPublisher.RaiseTestEvent1();
            testEventPublisher.RaiseTestEvent2();
            Assert.AreEqual(0, testEventSubscriber.HandleTestEvent1Count);
            Assert.AreEqual(1, testEventSubscriber.HandleTestEventPublisherTestEvent1Count);
        }
Пример #2
0
        public void AutoEventConnector_TestConnectDisconnect()
        {
            var testEventPublisher  = new TestEventPublisher();
            var testEventSubscriber = new TestEventSubscriber();

            testEventSubscriber.ConnectTo(testEventPublisher);

            testEventPublisher.RaiseTestEvent1();
            testEventPublisher.RaiseTestEvent2();
            Assert.AreEqual(0, testEventSubscriber.HandleTestEvent1Count);
            Assert.AreEqual(1, testEventSubscriber.HandleTestEventPublisherTestEvent1Count);

            testEventSubscriber.DisconnectFrom(testEventPublisher);

            testEventPublisher.RaiseTestEvent1();
            testEventPublisher.RaiseTestEvent2();
            Assert.AreEqual(0, testEventSubscriber.HandleTestEvent1Count);
            Assert.AreEqual(1, testEventSubscriber.HandleTestEventPublisherTestEvent1Count);
        }