コード例 #1
0
        public void DecrementToZeroInitial()
        {         //****************************************
            var MyCounter = new AsyncCounter(10);
            //****************************************

            var MyTask = MyCounter.DecrementToZero();

            //****************************************

            Assert.IsTrue(MyTask.IsCompleted, "Still waiting to decrement");
            Assert.AreEqual(10, MyTask.Result);

            Assert.AreEqual(0, MyCounter.CurrentCount, "Counter not decremented");
            Assert.AreEqual(0, MyCounter.WaitingCount, "Tasks unexpectedly waiting");
        }
コード例 #2
0
        public async Task DecrementToZeroAdd()
        {         //****************************************
            var MyCounter = new AsyncCounter();
            //****************************************

            var MyTask = MyCounter.DecrementToZero();

            Assert.IsFalse(MyTask.IsCompleted, "Decremented too early");

            MyCounter.Add(10);

            //****************************************

            Assert.AreEqual(10, await MyTask);

            Assert.AreEqual(0, MyCounter.CurrentCount, "Counter not decremented");
            Assert.AreEqual(0, MyCounter.WaitingCount, "Tasks unexpectedly waiting");
        }