public async Task WaitsIfNoSpaceAvailible() { using var s = new SemaphoreWrapper(1); await s.EnterQueue().OrTimeout(); var waitingTask = s.EnterQueue(); Assert.False(waitingTask.IsCompleted); s.LeaveQueue(); await waitingTask.OrTimeout(); }
public async Task TracksQueueLength() { using var s = new SemaphoreWrapper(1); Assert.Equal(1, s.Count); await s.EnterQueue().OrTimeout(); Assert.Equal(0, s.Count); s.LeaveQueue(); Assert.Equal(1, s.Count); }