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); }
public void AddCount_Overflow_ThrowsException() { var ce = new AsyncCountdownEvent(int.MaxValue); AssertEx.ThrowsException<InvalidOperationException>(() => ce.AddCount()); }
public void AddCount_AfterSet_ThrowsException() { var ce = new AsyncCountdownEvent(1); ce.Signal(); AssertEx.ThrowsException<InvalidOperationException>(() => ce.AddCount()); }