예제 #1
0
        public async Task TestReadAsync()
        {
            Assert.IsTrue(chained.CanRead, "Expected to be able to read from the chained stream.");

            do
            {
                int n     = (int)Math.Min(master.Length - master.Position, mbuf.Length);
                int nread = await chained.ReadAsync(cbuf, 0, n);

                int mread = await master.ReadAsync(mbuf, 0, n);

                Assert.AreEqual(mread, nread, "Did not read the expected number of bytes from the chained stream");
                Assert.AreEqual(master.Position, chained.Position, "The chained stream's position did not match");

                for (int i = 0; i < n; i++)
                {
                    Assert.AreEqual(mbuf[i], cbuf[i], "The bytes read do not match");
                }
            } while (master.Position < master.Length);
        }