diff --git a/src/DotNext.Tests/Threading/AsyncReaderWriterLockTests.cs b/src/DotNext.Tests/Threading/AsyncReaderWriterLockTests.cs index dc512c6a2..6fa4b857b 100644 --- a/src/DotNext.Tests/Threading/AsyncReaderWriterLockTests.cs +++ b/src/DotNext.Tests/Threading/AsyncReaderWriterLockTests.cs @@ -226,7 +226,7 @@ public static void DisposedWhenSynchronousWriteLockAcquired() [Fact] public static void AcquireReadWriteLockSynchronously() { - var l = new AsyncReaderWriterLock(); + using var l = new AsyncReaderWriterLock(); True(l.TryEnterReadLock(DefaultTimeout)); True(l.TryEnterReadLock(DefaultTimeout)); Equal(2L, l.CurrentReadCount); @@ -247,11 +247,11 @@ public static void AcquireReadWriteLockSynchronously() [Fact] public static void ResumeMultipleReadersSynchronously() { - var l = new AsyncReaderWriterLock(); + using var l = new AsyncReaderWriterLock(); True(l.TryEnterWriteLock()); - var t1 = new Thread(() => True(l.TryEnterReadLock(DefaultTimeout))) { IsBackground = true }; - var t2 = new Thread(() => True(l.TryEnterReadLock(DefaultTimeout))) { IsBackground = true }; + var t1 = new Thread(TryEnterReadLock) { IsBackground = true }; + var t2 = new Thread(TryEnterReadLock) { IsBackground = true }; t1.Start(); t2.Start(); @@ -260,5 +260,7 @@ public static void ResumeMultipleReadersSynchronously() True(t2.Join(DefaultTimeout)); Equal(2L, l.CurrentReadCount); + + void TryEnterReadLock() => True(l.TryEnterReadLock(DefaultTimeout)); } } \ No newline at end of file diff --git a/src/DotNext.Tests/Threading/AsyncResetEventTests.cs b/src/DotNext.Tests/Threading/AsyncResetEventTests.cs index b21866313..09c82ceb0 100644 --- a/src/DotNext.Tests/Threading/AsyncResetEventTests.cs +++ b/src/DotNext.Tests/Threading/AsyncResetEventTests.cs @@ -127,4 +127,15 @@ public static void ManualResetEventSynchronousCompletion(IAsyncResetEvent resetE Equal(resetEvent.ResetMode is EventResetMode.ManualReset, resetEvent.IsSet); } } + + [Theory] + [MemberData(nameof(GetResetEvents))] + public static void AlreadySignaledEvents(IAsyncResetEvent resetEvent) + { + using (resetEvent) + { + True(resetEvent.Signal()); + True(resetEvent.Wait(DefaultTimeout)); + } + } } \ No newline at end of file