示例#1
0
        public void Write_Not_Supported()
        {
            ActionStream actionStream = new ActionStream(new StreamActions());

            Assert.Throws <NotSupportedException>(() =>
            {
                byte[] buffer = new byte[1];
                actionStream.Write(buffer, 0, 1);
            });
        }
示例#2
0
        public void Write()
        {
            byte[]       expectedBuffer = new byte[10];
            ActionStream actionStream   = new ActionStream(new StreamActions
            {
                Write = (buffer, offset, count) =>
                {
                    for (int i = 0; i < count; i++)
                    {
                        expectedBuffer[i] = buffer[offset + i];
                    }
                }
            });

            byte[] writeBuffer = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            actionStream.Write(writeBuffer, 0, writeBuffer.Length);

            Assert.Equal(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, expectedBuffer);
        }