public void WhenWriterWritesWriterWaits() { ReaderWriterEntity rw = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait(() => rw.Write(100, 101), () => rw.Write(100, 101)); stopwatch.Stop(); Assert.GreaterOrEqual(stopwatch.ElapsedMilliseconds, 150); }
public void TwoReadersCanRead() { ReaderWriterEntity rw = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait(() => rw.Read(100), () => rw.Read(100)); stopwatch.Stop(); Assert.Less(stopwatch.ElapsedMilliseconds, 150); }
public void TwoObjectsCanWriteSimultaneously() { ReaderWriterEntity rw1 = new ReaderWriterEntity(); ReaderWriterEntity rw2 = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait(() => rw1.Write(100, 100), () => rw2.Write(100, 100)); stopwatch.Stop(); Assert.Less(stopwatch.ElapsedMilliseconds, 150); }
public void WhenWriterWritesWriterWaits() { ReaderWriterEntity rw = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait( () => rw.Write( 100, 101 ), () => rw.Write( 100, 101 ) ); stopwatch.Stop(); Assert.GreaterOrEqual( stopwatch.ElapsedMilliseconds, 150 ); }
public void TwoReadersCanRead() { ReaderWriterEntity rw = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait( () => rw.Read( 100 ), () => rw.Read( 100 ) ); stopwatch.Stop(); Assert.Less( stopwatch.ElapsedMilliseconds, 150 ); }
public void TwoObjectsCanWriteSimultaneously() { ReaderWriterEntity rw1 = new ReaderWriterEntity(); ReaderWriterEntity rw2 = new ReaderWriterEntity(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.InvokeSimultaneouslyAndWait( () => rw1.Write( 100, 100 ), () => rw2.Write( 100, 100 ) ); stopwatch.Stop(); Assert.Less( stopwatch.ElapsedMilliseconds, 150 ); }