Example #1
0
        public void TestCloseFuture()
        {
            DefaultCloseFuture future = new DefaultCloseFuture(null);
            Assert.IsFalse(future.Done);
            Assert.IsFalse(future.Closed);

            TestThread thread = new TestThread(future);
            thread.Start();

            future.Closed = true;
            thread.Join();

            Assert.IsTrue(thread.success);
            Assert.IsTrue(future.Done);
            Assert.IsTrue(future.Closed);
        }
Example #2
0
        public void TestRemoveListener2()
        {
            DefaultCloseFuture future = new DefaultCloseFuture(null);
            Assert.IsFalse(future.Done);
            Assert.IsFalse(future.Closed);

            IoFuture f1 = null, f2 = null;
            EventHandler<IoFutureEventArgs> listener1 = (s, e) => f1 = e.Future;
            EventHandler<IoFutureEventArgs> listener2 = (s, e) => f2 = e.Future;

            future.Complete += listener1;
            future.Complete += listener2;
            future.Complete -= listener2;

            TestThread thread = new TestThread(future);
            thread.Start();

            future.Closed = true;
            thread.Join();

            Assert.IsTrue(thread.success);
            Assert.IsTrue(future.Done);
            Assert.IsTrue(future.Closed);

            Assert.AreSame(future, f1);
            Assert.AreSame(null, f2);
        }
Example #3
0
        public void TestLateAddListener()
        {
            DefaultCloseFuture future = new DefaultCloseFuture(null);
            Assert.IsFalse(future.Done);
            Assert.IsFalse(future.Closed);

            TestThread thread = new TestThread(future);
            thread.Start();

            future.Closed = true;
            thread.Join();

            Assert.IsTrue(thread.success);
            Assert.IsTrue(future.Done);
            Assert.IsTrue(future.Closed);

            IoFuture f1 = null;
            future.Complete += (s, e) => f1 = e.Future;
            Assert.AreSame(future, f1);
        }