Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }