Пример #1
0
        public async Task WaitAsync_ReturnsTrue_WhenOpened_BeforeWaiting()
        {
            var threshold = TimeSpan.FromSeconds(1);
            var gate      = new ManualGate();

            gate.Open();

            var wasOpened = await gate.WaitAsync(threshold);

            Assert.True(wasOpened);
        }
Пример #2
0
        public async Task Open_AllowsMultipleThreads()
        {
            var gate = new ManualGate();

            gate.Open();

            var waitResult1 = await gate.WaitAsync(TimeSpan.Zero);

            var waitResult2 = await gate.WaitAsync(TimeSpan.Zero);

            Assert.True(waitResult1 && waitResult2);
        }
Пример #3
0
        public async Task Close_PreventsThreads_AfterBeginOpen()
        {
            var gate = new ManualGate();

            gate.Open();

            await gate.WaitAsync();

            gate.Close();

            var waitResult = await gate.WaitAsync(TimeSpan.FromSeconds(1));

            Assert.False(waitResult);
        }