Example #1
0
        public void ManagedStreamReadsByteCorrectly()
        {
            var data = new byte[1024];

            for (int i = 0; i < data.Length; i++)
            {
                data[i] = (byte)(i % byte.MaxValue);
            }

            var stream          = new MemoryStream(data);
            var skManagedStream = new SKManagedStream(stream);

            skManagedStream.Rewind();
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(0, skManagedStream.Position);

            for (int i = 0; i < data.Length; i++)
            {
                skManagedStream.Position = i;

                Assert.AreEqual(i, stream.Position);
                Assert.AreEqual(i, skManagedStream.Position);

                Assert.AreEqual((byte)(i % byte.MaxValue), data[i]);
                Assert.AreEqual((byte)(i % byte.MaxValue), skManagedStream.ReadByte());

                Assert.AreEqual(i + 1, stream.Position);
                Assert.AreEqual(i + 1, skManagedStream.Position);
            }
        }
Example #2
0
        public void ManagedStreamReadsByteCorrectly()
        {
            var data = new byte[1024];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = (byte)(i % byte.MaxValue);
            }

            var stream = new MemoryStream(data);
            var skManagedStream = new SKManagedStream(stream);

            skManagedStream.Rewind();
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(0, skManagedStream.Position);

            for (int i = 0; i < data.Length; i++)
            {
                skManagedStream.Position = i;

                Assert.AreEqual(i, stream.Position);
                Assert.AreEqual(i, skManagedStream.Position);

                Assert.AreEqual((byte)(i % byte.MaxValue), data[i]);
                Assert.AreEqual((byte)(i % byte.MaxValue), skManagedStream.ReadByte());

                Assert.AreEqual(i + 1, stream.Position);
                Assert.AreEqual(i + 1, skManagedStream.Position);
            }
        }
Example #3
0
        public void ManagedStreamReadsChunkCorrectly()
        {
            var data = new byte[1024];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = (byte)(i % byte.MaxValue);
            }

            var stream = new MemoryStream(data);
            var skManagedStream = new SKManagedStream(stream);

            skManagedStream.Rewind();
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(0, skManagedStream.Position);

            var buffer = new byte[data.Length / 2];
            skManagedStream.Read(buffer, buffer.Length);

            CollectionAssert.AreEqual(data.Take(buffer.Length), buffer);
        }
Example #4
0
        public void ManagedStreamReadsChunkCorrectly()
        {
            var data = new byte[1024];

            for (int i = 0; i < data.Length; i++)
            {
                data[i] = (byte)(i % byte.MaxValue);
            }

            var stream          = new MemoryStream(data);
            var skManagedStream = new SKManagedStream(stream);

            skManagedStream.Rewind();
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(0, skManagedStream.Position);

            var buffer = new byte[data.Length / 2];

            skManagedStream.Read(buffer, buffer.Length);

            Assert.AreEqual(data.Take(buffer.Length), buffer);
        }