public void FirkinStream_does_not_automatically_memorize_large_streams() { var stream = CreateStream(100000); var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, 90000); Assert.IsFalse(fs.IsMemorized); }
public void FirkinStream_memorizes_small_streams_automatically() { var stream = CreateStream(1000); var fs = new FirkinStream(new StreamSyncRoot(), stream, 0, 1000); Assert.IsTrue(fs.IsMemorized); }
public void Can_read_memorized_stream_in_single_chunk() { var stream = CreateStream(1000); var length = 500; var fs = new FirkinStream(new StreamSyncRoot(), stream, 100, (uint)length); var bytes = new byte[length]; Assert.AreEqual(length, fs.Read(bytes, 0, length)); stream.Position = 100; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_large_stream_directly_as_single_chunk() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); Assert.IsFalse(fs.IsMemorized); _log.Debug("starting read"); var bytes = fs.ReadBytes(); Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_memorize_large_stream() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); fs.Memorize(); Assert.IsTrue(fs.IsMemorized); var bytes = fs.ReadBytes(); Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_large_stream_directly_as_single_chunk() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); Assert.IsFalse(fs.IsMemorized); _log.Debug("starting read"); var bytes = fs.ReadBytes(); Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_memorize_large_stream() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); fs.Memorize(); Assert.IsTrue(fs.IsMemorized); var bytes = fs.ReadBytes(); Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_memorized_stream_in_small_chunks() { var stream = CreateStream(1000); var length = 500; var fs = new FirkinStream(new StreamSyncRoot(), stream, 100, (uint)length); var read = -1; var total = 0; var bytes = new byte[length]; while (read != 0) { read = fs.Read(bytes, total, 100); total += read; } Assert.AreEqual(length, total); stream.Position = 100; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_large_stream_directly_as_little_chunks() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); Assert.IsFalse(fs.IsMemorized); _log.Debug("starting read"); var read = -1; var total = 0; var bytes = new byte[length]; while(read != 0) { read = fs.Read(bytes, total, Math.Min(4 * 1024, bytes.Length - total)); total += read; } Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_large_stream_directly_as_little_chunks() { var stream = CreateStream(100000); var length = 90000; var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, length); Assert.IsFalse(fs.IsMemorized); _log.Debug("starting read"); var read = -1; var total = 0; var bytes = new byte[length]; while (read != 0) { read = fs.Read(bytes, total, Math.Min(4 * 1024, bytes.Length - total)); total += read; } Assert.AreEqual(length, bytes.Length); stream.Position = 1000; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void Can_read_memorized_stream_in_single_chunk() { var stream = CreateStream(1000); var length = 500; var fs = new FirkinStream(new StreamSyncRoot(), stream, 100, (uint)length); var bytes = new byte[length]; Assert.AreEqual(length, fs.Read(bytes, 0, length)); stream.Position = 100; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }
public void FirkinStream_memorizes_small_streams_automatically() { var stream = CreateStream(1000); var fs = new FirkinStream(new StreamSyncRoot(), stream, 0, 1000); Assert.IsTrue(fs.IsMemorized); }
public void FirkinStream_does_not_automatically_memorize_large_streams() { var stream = CreateStream(100000); var fs = new FirkinStream(new StreamSyncRoot(), stream, 1000, 90000); Assert.IsFalse(fs.IsMemorized); }
public void Can_read_memorized_stream_in_small_chunks() { var stream = CreateStream(1000); var length = 500; var fs = new FirkinStream(new StreamSyncRoot(), stream, 100, (uint)length); var read = -1; var total = 0; var bytes = new byte[length]; while(read != 0) { read = fs.Read(bytes, total, 100); total += read; } Assert.AreEqual(length, total); stream.Position = 100; Assert.AreEqual(0, stream.ReadBytes(length).Compare(bytes)); }