コード例 #1
0
 public void AddCount_IncrementsCount()
 {
     var ce = new AsyncCountdownEvent(1);
     var task = ce.WaitAsync();
     Assert.AreEqual(1, ce.CurrentCount);
     Assert.IsFalse(task.IsCompleted);
     ce.AddCount();
     Assert.AreEqual(2, ce.CurrentCount);
     Assert.IsFalse(task.IsCompleted);
     ce.Signal();
     Assert.AreEqual(1, ce.CurrentCount);
     Assert.IsFalse(task.IsCompleted);
     ce.Signal();
     Assert.AreEqual(0, ce.CurrentCount);
     Assert.IsTrue(task.IsCompleted);
 }
コード例 #2
0
 public void AddCount_Overflow_ThrowsException()
 {
     var ce = new AsyncCountdownEvent(int.MaxValue);
     AssertEx.ThrowsException<InvalidOperationException>(() => ce.AddCount());
 }
コード例 #3
0
 public void AddCount_AfterSet_ThrowsException()
 {
     var ce = new AsyncCountdownEvent(1);
     ce.Signal();
     AssertEx.ThrowsException<InvalidOperationException>(() => ce.AddCount());
 }