예제 #1
0
        public void Remove_NotEmpty()
        {
            var user1 = this._network.GetUser("alice");
            var pair1 = new IrcUserChannelModePair(user1, IrcChannelUserModes.Op);
            var user2 = this._network.GetUser("bob");
            var pair2 = new IrcUserChannelModePair(user2, IrcChannelUserModes.Admin);
            var coll = new IrcUserModeCollection();
            int firedCount = 0, firedUsersCount = 0;

            ((INotifyCollectionChanged)coll).CollectionChanged += (s, e) =>
            {
                firedCount++;
            };
            ((INotifyCollectionChanged)coll.Users).CollectionChanged += (s, e) =>
            {
                firedUsersCount++;
            };
            coll.Add(pair1);
            coll.Add(pair2);
            coll.Remove(pair1);

            Assert.AreEqual(1, coll.Count);
            Assert.IsTrue(coll.Contains(pair2));
            Assert.AreEqual(3, firedCount);
            Assert.AreEqual(3, firedUsersCount);
        }
예제 #2
0
        public void Remove_Empty()
        {
            var user = this._network.GetUser("alice");
            var pair = new IrcUserChannelModePair(user, IrcChannelUserModes.Op);
            var coll = new IrcUserModeCollection();
            int firedCount = 0, firedUsersCount = 0;

            ((INotifyCollectionChanged)coll).CollectionChanged += (s, e) =>
            {
                firedCount++;
            };
            ((INotifyCollectionChanged)coll.Users).CollectionChanged += (s, e) =>
            {
                firedUsersCount++;
            };
            coll.Add(pair);
            coll.Remove(pair);

            Assert.AreEqual(0, coll.Count);
            Assert.AreEqual(2, firedCount);
            Assert.AreEqual(2, firedUsersCount);
        }