public void AddingSubscriptionsReturnsCorrectNumberOfElements()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();
            MockSubscription           subscription  = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Assert.AreEqual(2, subscriptions.Count);
        }
        public void IndexThrowsForNegativeIndex()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Subscription test = subscriptions[-1];
        }
        public void IndexThrowsForPastEndOfList()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Subscription test = subscriptions[2];
        }
        public void IndexerThrowsWhenNotMatch()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Subscription test = subscriptions["not"];
        }
        public void FindViaSubscriberReturnsCorrectResults()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Assert.AreEqual(0, subscriptions.Find("test"));
            Assert.AreEqual(1, subscriptions.Find("another"));
            Assert.AreEqual(-1, subscriptions.Find("not"));
        }
        public void ContainsKeyPerformsCorrectly()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Assert.IsTrue(subscriptions.ContainsKey("test"));
            Assert.IsTrue(subscriptions.ContainsKey("another"));
            Assert.IsFalse(subscriptions.ContainsKey("not"));
        }
        public void IntegerIndexerGetsCorrectSubscription()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Subscription test = subscriptions[1];

            Assert.IsNotNull(test);
            Assert.AreEqual("anotherPub", test.Publication);
        }
        public void IndexFindsSubscriptionUsingSubscriber()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription);

            subscription = new MockSubscription("another", "anotherPub");
            subscriptions.Add(subscription);

            Subscription test = subscriptions["another"];

            Assert.IsNotNull(test);
            Assert.AreEqual("anotherPub", test.Publication);
        }
        public void ContainsReturnsTrueOnlyForExactSameInstance()
        {
            MockSubscriptionCollection subscriptions = new MockSubscriptionCollection();

            MockSubscription subscription1 = new MockSubscription("test", "testPub");

            subscriptions.Add(subscription1);

            MockSubscription subscription2 = new MockSubscription("another", "anotherPub");

            subscriptions.Add(subscription2);

            MockSubscription subscription3 = new MockSubscription("test", "testPub");

            Assert.IsTrue(subscriptions.Contains(subscription1));
            Assert.IsFalse(subscriptions.Contains(subscription3));
        }