public void WeakEventManager_AddWeakEventListener_FiresEventAfterGC_Test()
        {
            Setup();

            GC.Collect();

            _publisher.Fire();

            Assert.AreEqual(1, _subscriber.Invocations);
        }
        public void WeakEventManager_AddWeakEventListener_FiresEvent_Test()
        {
            var publisher  = new TestPublisher();
            var subscriber = new TestSubscriber(publisher);

            publisher.Fire();

            Assert.AreEqual(1, subscriber.Invocations);
        }
        public void WeakEventManager_RemoveWeakEventListener_EventNoLongerFires_Test()
        {
            var publisher  = new TestPublisher();
            var subscriber = new TestSubscriber(publisher);

            subscriber.Stop();
            publisher.Fire();

            Assert.AreEqual(0, subscriber.Invocations);
        }
        public void WeakEventManager_ClearWeakEventListeners_ClearsAllListeners_Test()
        {
            var publisher1 = new TestPublisher();
            var publisher2 = new TestPublisher();
            var subscriber = new TestSubscriber(publisher1);

            subscriber.Start(publisher2);

            subscriber.Clear();
            publisher1.Fire();
            publisher2.Fire();

            Assert.AreEqual(0, subscriber.Invocations);
        }