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); }
public void Remove_WithNoSubscriptionAdded_DoesNothing() { // Arrange var cache = new SubscriptionsCache(); // Act TestDelegate remove = () => cache.Remove <Topic>(subscriber); // Assert Assert.That(remove, Throws.Nothing); }
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); }
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); }