Write() public method

Writes a block of bytes into the stream.
public Write ( byte buffer, int offset, int count ) : void
buffer byte The byte data to write into the stream
offset int The zero-based byte offset in buffer from which to begin copying bytes to the current stream.
count int The maximum number of bytes to write.
return void
Exemplo n.º 1
0
        public void TestWriteZeroBytes()
        {
            byte[] buf = new byte[0];
            MemoryBlockStream ms = new MemoryBlockStream();
            ms.Write(buf, 0, 0);
            Assert.AreEqual(ms.Length, 0);

            XorShiftRandom rng = new XorShiftRandom(1234567);
            byte[] buf2 = new byte[100];
            rng.NextBytes(buf2);
            ms.Write(buf2, 0, buf2.Length);

            if(!Utils.AreEqual(ms.ToArray(), buf2)) Assert.Fail();

            ms.Write(buf, 0, 0);
            Assert.AreEqual(ms.Length, buf2.Length);
        }