示例#1
0
        public void Remove_WhenCalledForSameSubscriberTwice_UnsubscribesOnce()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);

            // Act
            cache.Remove <Topic>(subscriber);
            cache.Remove <Topic>(subscriber);

            // Assert
            mockSubscriber.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
示例#2
0
        public void Remove_WithNoSubscriptionAdded_DoesNothing()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            // Act
            TestDelegate remove = () => cache.Remove <Topic>(subscriber);

            // Assert
            Assert.That(remove, Throws.Nothing);
        }
示例#3
0
        public void Remove_WithSubscriptionAdded_CallsSubscriberUnsubscribe()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);

            // Act
            cache.Remove <Topic>(subscriber);

            // Assert
            mockSubscriber.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }
示例#4
0
        public void Remove_WithTwoSubscriptionsAdded_CallsCorrectUnsubscribe_2()
        {
            // Arrange
            var cache = new SubscriptionsCache();

            cache.Add <Topic>(subscriber);
            cache.Add <Topic>(subscriber2);

            // Act
            cache.Remove <Topic>(subscriber2);

            // Assert
            mockSubscriber2.Verify(m => m.Unsubscribe <Topic>(), Times.Once);
        }