This library provides a collection of fake stream for testing. A constant stream is an lazy stream (not backed by a base stream) and provide a basic reading operations of a stream of bytes (the same byte or stride of bytes). The streams imitate a NetworkStream by providing only the "Read" operation and not "Seek", "Length" or "Write".
$ dotnet add package ConstantStreamA collections of fake streams for testing purposes.
The library have tree Stream types:
For example:
ConstantByteStream(5, (byte) 'A'); // Should read as "AAAAA"
ConstantStrideStream(10, Encoding.UTF8.GetBytes("ABC")); // Should read as "ABCABCABCA"
var timedStream = new TimedStream(1024, (byte)'c'); // Just like a constant byte stream
timeStream.Delays.Add(0, TimeSpan.FromMilliseconds(200)); // add a wait in position 0 of 200 ms
timeStream.Delays.Add(15, TimeSpan.FromMilliseconds(250)); // add a wait in position 15 of 250 ms
timeStream.Delays.Add(1000, TimeSpan.FromMinutes(1)); // add a wait in position 1000 of 1 min
// the timedStream should take about 1 minute + 450 ms + reading overhead(ms) to read in total
// Creates a 1 Mb stream of zeroes.
var zeroesStream = new ConstantByteStream(1024*1024, (byte)0);
// Creates a 1 Gb stream full of 's'.
var sStream = new ConstantByteStream(1024*1020*1020, (byte)'s');
// Handy factory method (From*)
var zeroesStreamEasy = ConstantByteStream.FromZeroes(1024*1020);
The Stream doesnt have a base stream. Its a fake generator and provide a simple Stream that generates large amounts of data.