public static void ShouldNotBeOwnerForRestoreLockTest()
{
var trwl = new TestReaderWriterLock();
trwl.AcquireReaderLock();
TestLockCookie restoreReadLockTlc = trwl.ReleaseLock();
trwl.AcquireWriterLock();
TestLockCookie restoreWriteLockTlc = trwl.ReleaseLock();
Action verifyCannotRestore =
() =>
{
Assert.Throws<SynchronizationLockException>(() => trwl.RestoreLock(restoreReadLockTlc));
Assert.Throws<SynchronizationLockException>(() => trwl.RestoreLock(restoreWriteLockTlc));
};
trwl.AcquireReaderLock();
verifyCannotRestore();
trwl.ReleaseReaderLock();
trwl.AcquireWriterLock();
verifyCannotRestore();
trwl.ReleaseWriterLock();
trwl.Dispose();
}