Ejemplo n.º 1
0
        public void TestDoubleSubscribeRemove()
        {
            TargetClass target = new TargetClass();
            MulticastWeakDelegate <Action> testInst = new MulticastWeakDelegate <Action>();

            testInst.Add(target.TestMethod);
            testInst.Add(target.TestMethod);
            testInst.Remove(target.TestMethod);
            testInst.GetDelegate()();
            Assert.AreEqual(1, target.CallCount);
        }
Ejemplo n.º 2
0
        public void TestCallStrongTwice()
        {
            int callCount = 0;

            MulticastWeakDelegate <Action> testInst = new MulticastWeakDelegate <Action>();

            testInst.Add(() => callCount++);
            testInst.Add(() => callCount++);

            var d = testInst.GetDelegate();

            Assert.IsNotNull(d);
            d();

            Assert.AreEqual(2, callCount);
        }
Ejemplo n.º 3
0
        private void Subscribe(MulticastWeakDelegate <Action> weakDeleg)
        {
            TargetClass target = new TargetClass();

            weakDeleg.Add(new Action(target.TestMethod));
        }