public void Handler_ShouldThrowException_WhenUnsubscribing_WhenUnsubscribedTwice() { //Arrange var handler = new Handler(); var subscription = new ContextlessSubscription(); handler.Subscribe(subscription); //Act //Assert handler.Unsubscribe(subscription); Assert.ThrowsException <ArgumentException>(() => handler.Unsubscribe(subscription)); }
public void Handler_ShouldThrowException_WhenUnsubscribing_WhenEventIsNotSubscribed() { //Arrange var handler = new Handler(); var subscription = new ContextfulSubscription(); //Act //Assert Assert.ThrowsException <ArgumentException>(() => handler.Unsubscribe(subscription)); }
public void Handler_ShouldNotNotify_WhenSubscriptionRemoved() { //Arrange var subscriptionCalled = false; var handler = new Handler(); var subscription = handler.Subscribe <ContextlessEvent>(() => { subscriptionCalled = true; }); handler.Unsubscribe(subscription); //Act handler.Dispatch <ContextlessEvent>(); //Assert Assert.IsFalse(subscriptionCalled); }