Beispiel #1
0
        public void Dequeue_EndEnqueue_IsComplete()
        {
            var queue = new WaitQueue<int>();
            var task1 = queue.Enqueue(item0, none);
            var task2 = queue.Enqueue(item1, none);

            Test.Async(async () =>
            {
                await task1;
                await task2;
                Assert.IsFalse(await queue.IsEmpty(none));
                Assert.IsFalse(await queue.IsComplete(none));
                Assert.IsFalse(await queue.IsEnded(none));
                await queue.EndEnqueue(none);
                Assert.IsTrue(await queue.IsEnded(none));
                Assert.IsFalse(await queue.IsEmpty(none));
                Assert.IsFalse(await queue.IsComplete(none));
                while (queue.Count > 0)
                    await queue.Dequeue(none);
                Assert.IsTrue(await queue.IsComplete(none));
                Assert.IsTrue(await queue.IsEmpty(none));
                Assert.IsTrue(await queue.IsEnded(none));
            });

            Assert.IsTrue(task1.IsCompleted);
            Assert.IsTrue(task2.IsCompleted);
        }