/// <summary> /// Reads data from the stream into the specified buffer. /// </summary> /// <param name="buffer"></param> /// <param name="offset"></param> /// <param name="count"></param> /// <returns></returns> public override int Read(byte[] buffer, int offset, int count) { int bytesRead = _data.Copy(Position, buffer, offset, count); Position += bytesRead; return(bytesRead); }
public void TestCopyFromStream_Small() { NcByteCollection b1 = new NcByteCollection(NcTestUtils.RandomBytes(30 * 1000)); NcByteStream b2 = new NcByteStream(NcTestUtils.RandomBytes(1000)); b1.Copy(b2, 5000, 50); Assert.IsTrue(b1.Count == (30 * 1000)); Assert.IsTrue(b1.SequenceEqual(b1.Take(5000).Concat(b2.Data.Take(50)).Concat(b1.Skip(5050)))); }
public void TestCopyToStream() { NcByteCollection data = new NcByteCollection(NcTestUtils.RandomBytes(12 * 1024)); MemoryStream ms = new MemoryStream(); data.Copy(3 * 1024, ms, 5 * 1024); Assert.IsTrue(ms.ToArray().SequenceEqual(data.Skip(3 * 1024).Take(5 * 1024))); }
public void TestCopyFromArray_Small() { NcByteCollection b1 = new NcByteCollection(NcTestUtils.RandomBytes(30 * 1000)); byte[] b2 = NcTestUtils.RandomBytes(1000); b1.Copy(b2, 0, 5000, 50); Assert.IsTrue(b1.Count == (30 * 1000)); Assert.IsTrue(b1.SequenceEqual(b1.Take(5000).Concat(b2.Take(50)).Concat(b1.Skip(5050)))); }