Exemplo n.º 1
0
        public void Read_Not_Supported()
        {
            ActionStream actionStream = new ActionStream(new StreamActions());

            Assert.Throws <NotSupportedException>(() =>
            {
                byte[] buffer = new byte[1];
                actionStream.Read(buffer, 0, 1);
            });
        }
Exemplo n.º 2
0
        public void Read_Content()
        {
            ActionStream actionStream = new ActionStream(new StreamActions {
                Read = (buffer, offset, count) =>
                {
                    for (int i = 0; i < count; i++)
                    {
                        buffer[offset + i] = (byte)i;
                    }
                    return(count);
                }
            });

            byte[] readBuffer = new byte[10];
            actionStream.Read(readBuffer, 0, readBuffer.Length);

            Assert.Equal(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, readBuffer);
        }
Exemplo n.º 3
0
        public void Read_Length()
        {
            ActionStream actionStream = new ActionStream(new StreamActions
            {
                Read = (buffer, offset, count) =>
                {
                    for (int i = 0; i < count; i++)
                    {
                        buffer[offset + i] = (byte)i;
                    }
                    return(count);
                }
            });

            byte[] readBuffer = new byte[10];
            int    readLength = actionStream.Read(readBuffer, 0, readBuffer.Length);

            Assert.Equal(readBuffer.Length, readLength);
        }