Пример #1
0
        public void Adding()
        {
            var topics = new TopicManager();

            Assert.AreEqual(0, topics.GetPeers("alpha").Count());

            topics.AddInterest("alpha", a);
            Assert.AreEqual(a, topics.GetPeers("alpha").First());

            topics.AddInterest("alpha", b);
            var peers = topics.GetPeers("alpha").ToArray();

            CollectionAssert.Contains(peers, a);
            CollectionAssert.Contains(peers, b);
        }
Пример #2
0
        public void Adding_Duplicate()
        {
            var topics = new TopicManager();

            Assert.AreEqual(0, topics.GetPeers("alpha").Count());

            topics.AddInterest("alpha", a);
            Assert.AreEqual(1, topics.GetPeers("alpha").Count());

            topics.AddInterest("alpha", a);
            Assert.AreEqual(1, topics.GetPeers("alpha").Count());

            topics.AddInterest("alpha", b);
            Assert.AreEqual(2, topics.GetPeers("alpha").Count());
        }
Пример #3
0
        public void Clearing()
        {
            var topics = new TopicManager();

            Assert.AreEqual(0, topics.GetPeers("alpha").Count());
            Assert.AreEqual(0, topics.GetPeers("beta").Count());

            topics.AddInterest("alpha", a);
            topics.AddInterest("beta", b);
            Assert.AreEqual(1, topics.GetPeers("alpha").Count());
            Assert.AreEqual(1, topics.GetPeers("beta").Count());

            topics.Clear();
            Assert.AreEqual(0, topics.GetPeers("alpha").Count());
            Assert.AreEqual(0, topics.GetPeers("beta").Count());
        }
Пример #4
0
        public void Removing()
        {
            var topics = new TopicManager();

            Assert.AreEqual(0, topics.GetPeers("alpha").Count());

            topics.AddInterest("alpha", a);
            topics.AddInterest("alpha", b);
            Assert.AreEqual(2, topics.GetPeers("alpha").Count());

            topics.RemoveInterest("alpha", a);
            Assert.AreEqual(b, topics.GetPeers("alpha").First());
            Assert.AreEqual(1, topics.GetPeers("alpha").Count());

            topics.RemoveInterest("alpha", a);
            Assert.AreEqual(b, topics.GetPeers("alpha").First());
            Assert.AreEqual(1, topics.GetPeers("alpha").Count());

            topics.RemoveInterest("alpha", b);
            Assert.AreEqual(0, topics.GetPeers("alpha").Count());

            topics.RemoveInterest("beta", b);
            Assert.AreEqual(0, topics.GetPeers("beta").Count());
        }