Esempio n. 1
0
        public void Setup()
        {
            _target = new MessageAggregator();

            _listenerA  = new ListenerA();
            _listenerAB = new ListenerAB();
        }
Esempio n. 2
0
        public async Task Publish_Removes_Zombie_References()
        {
            _target.AddListener(_listenerA);
            _target.AddListener(_listenerAB);

            _listenerA = null; // De-reference the listener
            GC.Collect(0);     // Force the Garbage Collector into action.

            await _target.Publish(new ObservableA()).ConfigureAwait(false);

            _target.Subscriptions.TryGetValue(typeof(IListenFor <ObservableA>), out var subscribers);

            Assert.IsNotNull(subscribers);
            Assert.AreEqual(1, subscribers.Count);
        }