Exemplo n.º 1
0
        public void ReadBlocksUntilWrite()
        {
            ThreadPool.QueueUserWorkItem(state =>
            {
                syncEvent1.Set();

                Assert.Contains("Sample Data", Encoding.ASCII.GetString(buffer.Read()));

                syncEvent2.Set();
            });

            syncEvent1.WaitOne();

            Assert.False(syncEvent2.WaitOne(TimeSpan.FromMilliseconds(100)));

            buffer.Write(Encoding.ASCII.GetBytes("Sample Data"));

            Assert.True(syncEvent2.WaitOne());
        }
        public void CannotWriteToDisposedObject()
        {
            buffer.Dispose();

            Assert.Throws <ObjectDisposedException>(() => buffer.Write(new Byte[0]));
        }