public void ListenersAddAllTest()
        {
            Listeners l1 = new Listeners();
            Listeners l2 = new Listeners();

            DummyEventListener d1 = new DummyEventListener();
            DummyEventListener d2 = new DummyEventListener();
            DummyEventListener d3 = new DummyEventListener();

            l2.Add(d2);
            l2.Add(d3);

            Assert.AreEqual(l1.ListenersArray.Length, 0);
            l1.AddAll(null);
            Assert.AreEqual(l1.ListenersArray.Length, 0);
            l1.AddAll(l2);
            Assert.AreEqual(l1.ListenersArray.Length, 2);
            Assert.AreEqual(l1.ListenersArray[0], l2.ListenersArray[0]);
            Assert.AreEqual(l1.ListenersArray[1], l2.ListenersArray[1]);

            l1.AddAll(l2);
            Assert.AreEqual(l1.ListenersArray.Length, 2);

            l1.RemoveAll();
            l1.Add(d1);
            l1.AddAll(l2);

            Assert.AreEqual(l1.ListenersArray.Length, 3);
            foreach (ICacheListener listener in l2.ListenersArray)
            {
                Assert.IsTrue(l1.Contains(listener));
            }

            Listeners l3 = new Listeners();
            Listeners l4 = new Listeners();

            DummySyncEventListener s1 = new DummySyncEventListener();
            DummySyncEventListener s2 = new DummySyncEventListener();

            l4.Add(s1);
            l4.Add(s2);
            l3.Add(d1);
            l3.AddAll(l4);

            Assert.AreEqual(l3.ListenersArray.Length, 3);
            foreach (ICacheListener listener in l4.ListenersArray)
            {
                Assert.IsTrue(l3.Contains(listener));
            }

            l1.AddAll(l3);
            Assert.AreEqual(l1.ListenersArray.Length, 5);
        }
        public void ListenersAddRemoveTest()
        {
            Listeners l = new Listeners();

            Assert.IsTrue(l.IsEmpty);

            DummyEventListener d1 = new DummyEventListener();
            DummyEventListener d2 = new DummyEventListener();
            DummyEventListener d3 = new DummyEventListener();

            l.Add(d1);
            Assert.IsFalse(l.IsEmpty);
            Assert.IsTrue(l.Contains(d1));
            Assert.AreEqual(l.ListenersArray.Length, 1);
            l.Add(null);
            Assert.AreEqual(l.ListenersArray.Length, 1);
            l.Add(d1);
            Assert.AreEqual(l.ListenersArray.Length, 1);
            l.Add(d2);
            Assert.IsTrue(l.Contains(d2));
            Assert.AreEqual(l.ListenersArray.Length, 2);

            l.Remove(null);
            Assert.AreEqual(l.ListenersArray.Length, 2);
            l.Remove(d3);
            Assert.AreEqual(l.ListenersArray.Length, 2);
            l.Remove(d1);
            Assert.AreEqual(l.ListenersArray.Length, 1);
            Assert.IsFalse(l.Contains(d1));
            Assert.IsTrue(l.Contains(d2));
            l.Remove(d1);
            Assert.AreEqual(l.ListenersArray.Length, 1);

            l.RemoveAll();
            Assert.IsTrue(l.IsEmpty);
            Assert.IsFalse(l.Contains(d2));

            DummySyncEventListener s1 = new DummySyncEventListener();

            l.Add(s1);
            Assert.IsTrue(l.Contains(s1));
            Assert.AreEqual(l.ListenersArray.Length, 1);
            l.Add(d1);
            Assert.AreEqual(l.ListenersArray.Length, 2);
            l.Remove(s1);
            Assert.IsTrue(l.Contains(d1));
            Assert.AreEqual(l.ListenersArray.Length, 1);
            l.Remove(d1);
            Assert.IsTrue(l.IsEmpty);
        }