예제 #1
0
        public void TestAction()
        {
            Assert.IsNull(this.testActionEvent);

            var subscriber = new Subscriber(this.fiber, this.Pulse);
            this.testActionEvent += subscriber;

            try
            {
                Assert.IsNotNull(this.testActionEvent);

                lock (this.pulser)
                {
                    this.testActionEvent();
                    Assert.IsTrue(Monitor.Wait(this.pulser, 20000));
                }

                this.testActionEvent -= subscriber;

                Assert.IsNull(this.testActionEvent);
            }
            finally
            {
                this.testActionEvent = null;
            }
        }
예제 #2
0
        public void TestActionObjectHandler()
        {
            Assert.IsNull(this.testActionObjectEvent);

            var subscriber = new Subscriber<object>(this.fiber, Pulse);
            this.testActionObjectEvent += subscriber;

            try
            {
                Assert.IsNotNull(this.testActionObjectEvent);

                lock (pulser)
                {
                    this.testActionObjectEvent(this.pulser);
                    Assert.IsTrue(Monitor.Wait(this.pulser, 20000));
                }

                this.testActionObjectEvent -= subscriber;

                Assert.IsNull(this.testActionObjectEvent);
            }
            finally
            {
                this.testActionObjectEvent = null;
            }
        }
예제 #3
0
        public void TestTwoArguments()
        {
            Assert.IsNull(this.testActionObjectObjectEvent);

            var subscriber = new Subscriber<object, object>(this.fiber, Pulse);
            this.testActionObjectObjectEvent += subscriber;

            try
            {
                Assert.IsNotNull(this.testActionObjectObjectEvent);

                lock (pulser)
                {
                    this.testActionObjectObjectEvent(this.pulser, 2);
                    Assert.IsTrue(Monitor.Wait(this.pulser, 20000), "Event handler not called");
                }

                this.testActionObjectObjectEvent -= subscriber;

                Assert.IsNull(this.testActionObjectObjectEvent);
            }
            finally
            {
                this.testActionObjectObjectEvent = null;
            }
        }