if (assertEnabled) { Thread.Sleep(100); }
if (assertEnabled) { Interlocked.Increment(ref writerCount); Thread.Sleep(100); Assert.AreEqual(1, writerCount); Assert.AreEqual(0, readerCount, "trying to write while reading"); } // the implementation of the method go here if (assertEnabled) { Interlocked.Decrement(ref writerCount); }
[Test] public void WriterWaitForReader() { Thread r1 = CreateReader(); Thread w1 = CreateWriter(); r1.Join(); w1.Join(); Assert.That(exception, Is.Null); }
rwLock.AcquireWriterLock(InfiniteTimeOut); if (assertEnabled) { Interlocked.Increment(ref writerCount); Thread.Sleep(100); Assert.AreEqual(1, writerCount); Assert.AreEqual(0, readerCount, "trying to write while reading"); } // the implementation of the method go here if (assertEnabled) { Interlocked.Decrement(ref writerCount); } rwLock.ReleaseLock();
Posted in Automated Testing | Concurrency | TDD | Test-Driven |Comments [2]
Remember Me
BestBrains is a software consultancy company that help others improve the way they are developing software. See our main site at www.bestbrains.dk.