public void ConstructorThrowsLockRecursionExceptionWhenLockIsNotUpdatableTest() { var _lock = new ReaderWriterLockSlim(); var _readerLock = new ReaderLock(_lock); Assert.Throws<System.Threading.LockRecursionException>(() => new WriterLock(_readerLock)); Assert.IsNotNull(_lock); }
public void ConstructorInitializesLockTest() { var _lock = new ReaderWriterLockSlim(); using (var _readerLock = new ReaderLock(_lock)) { Assert.AreEqual(_lock, _readerLock.Lock); } Assert.IsNotNull(_lock); }
public void ConstructorInitializesIsUpgradableTest() { const bool IS_UPGRADABLE = true; var _lock = new ReaderWriterLockSlim(); using (var _readerLock = new ReaderLock(_lock, -1, IS_UPGRADABLE)) { Assert.AreEqual(IS_UPGRADABLE, _readerLock.IsUpgradable); } }
public void ConstructorInitializesTimeoutTest() { const int TIMEOUT = 100; var _lock = new ReaderWriterLockSlim(); using (var _readerLock = new ReaderLock(_lock, TIMEOUT)) { Assert.AreEqual(TIMEOUT, _readerLock.Timeout); } Assert.IsNotNull(_lock); }
public void ConstructorAquiresLockWhenIsUpgradableTest() { var _lock = new ReaderWriterLockSlim(); using (var _readerLock = new ReaderLock(_lock, -1, true)) { Assert.AreEqual(_lock, _readerLock.Lock); Assert.IsTrue(_readerLock.Lock.IsUpgradeableReadLockHeld); } Assert.IsNotNull(_lock); Assert.IsFalse(_lock.IsUpgradeableReadLockHeld); }
public WriterLock(ReaderLock _readerLock) : base(_readerLock.Lock, _readerLock.Timeout) { if (!this.Lock.IsUpgradeableReadLockHeld) throw new InvalidOperationException("!this.Lock.IsUpgradeableReadLockHeld"); }
public void DisposeReleasesLockWhenIsUpgradableTest() { var _lock = new ReaderWriterLockSlim(); using (var _readerLock = new ReaderLock(_lock)) { Assert.AreEqual(_lock, _readerLock.Lock); } Assert.IsNotNull(_lock); Assert.IsFalse(_lock.IsUpgradeableReadLockHeld); }