示例#1
0
        public void PaCa()
        {
            AsynchronousConsumer();
            stream = new OutputStream(next, complete);

            IAsyncResult latest = null;
            var iasr0 = BeginWriteString("asdf", iasr => latest = iasr);

            ct();

            Assert.IsFalse(iasr0.CompletedSynchronously);
            Assert.AreSame(iasr0, latest);

            var iasr1 = BeginWriteString("jkl;", iasr => latest = iasr);

            ct();

            Assert.IsFalse(iasr1.CompletedSynchronously);
            Assert.AreSame(iasr1, latest);

            var iasr2 = BeginWriteString("lol", iasr => latest = iasr);

            ct();

            Assert.IsFalse(iasr2.CompletedSynchronously);
            Assert.AreSame(iasr2, latest);

            stream.Dispose();

            Assert.IsTrue(completed);
            Assert.AreEqual("asdfjkl;lol", sb.ToString());
        }
示例#2
0
        public void PaCs()
        {
            SynchronousConsumer();
            stream = new OutputStream(next, complete);

            Assert.IsTrue(BeginWriteString("asdf", iasr => { stream.EndWrite(iasr); }).CompletedSynchronously);
            Assert.IsTrue(BeginWriteString("jkl;", iasr => { stream.EndWrite(iasr); }).CompletedSynchronously);
            Assert.IsTrue(BeginWriteString("lol", iasr => { stream.EndWrite(iasr); }).CompletedSynchronously);
            stream.Dispose();

            Assert.IsTrue(completed);
            Assert.AreEqual("asdfjkl;lol", sb.ToString());
        }
示例#3
0
        public void PsCa()
        {
            AsynchronousConsumer();

            stream = new OutputStream(next, complete);

            WriteString("asdf");
            WriteString("jkl;");
            WriteString("lol");
            stream.Dispose();

            Assert.IsTrue(completed);
            Assert.AreEqual("asdfjkl;lol", sb.ToString());
        }
示例#4
0
 public void SetUp()
 {
     sb = new StringBuilder();
     complete = () => completed = true;
     next = null;
     completed = false;
     stream = null;
 }