Exemple #1
0
        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));
        }
Exemple #2
0
        public void Handler_ShouldThrowException_WhenUnsubscribing_WhenEventIsNotSubscribed()
        {
            //Arrange
            var handler      = new Handler();
            var subscription = new ContextfulSubscription();

            //Act
            //Assert
            Assert.ThrowsException <ArgumentException>(() => handler.Unsubscribe(subscription));
        }
Exemple #3
0
        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);
        }