Exemplo n.º 1
0
        public void DoubleDisposeShouldNotFailForLockHandle()
        {
            var handle = _lockSet.TryAcquire("key1");

            handle.Should().NotBeNull();
            handle.Value.Dispose();
            // Dispose pattern implies that double dispose should never fail.
            handle.Value.Dispose();
        }
Exemplo n.º 2
0
        public void AcquireImmediately()
        {
            var lockSet = new LockSet <string>();

            using (var handle = lockSet.TryAcquire("key1"))
            {
                handle.Should().NotBeNull();
            }
        }
Exemplo n.º 3
0
        public async Task AcquireImmediatelyNotBlockedAndReturnsNullWhenKeyHeld()
        {
            var lockSet = new LockSet <string>();

            using (await lockSet.AcquireAsync("key1"))
            {
                using (var handle = lockSet.TryAcquire("key1"))
                {
                    handle.Should().BeNull();
                }
            }
        }