示例#1
0
        public void Setup()
        {
            _target = new MessageAggregator();

            _listenerA  = new ListenerA();
            _listenerAB = new ListenerAB();
        }
示例#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);
        }