Ejemplo n.º 1
0
    public void WeakEventManager_RemoveWeakEventListener_EventNoLongerFires()
    {
        var source = new Mock <INotifyPropertyChanged>();

        var invocations = 0;

        var wem = new WeakEventManager();

        wem.AddWeakEventListener <INotifyPropertyChanged, PropertyChangedEventArgs>(
            source.Object,
            nameof(INotifyPropertyChanged.PropertyChanged),
            (s, a) =>
        {
            s.ShouldBe(source.Object);

            invocations++;
        }
            );

        wem.RemoveWeakEventListener(source.Object);

        source.Raise(x => x.PropertyChanged += null, new PropertyChangedEventArgs("Foo"));

        invocations.ShouldBe(0);
    }
 public void Stop()
 {
     _manager.RemoveWeakEventListener(Publisher);
 }