public void Setup() { _target = new MessageAggregator(); _listenerA = new ListenerA(); _listenerAB = new ListenerAB(); }
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); }