public IStreamConsumer CreateConsumer(ContentInfo contentInfo) => StreamConsumer.ToStream(new FileStream( AbsolutePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite, BufferSize ?? DefaultBufferSize, FileOptions.WriteThrough | FileOptions.Asynchronous ), BufferSize ?? DefaultBufferSize);
public async Task Stream() { var seed = Encoding.ASCII.GetBytes(@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce elementum nisi vel magna rhoncus, in aliquam ipsum accumsan. Phasellus efficitur lectus quis malesuada aliquet. Proin mattis sagittis magna vitae blandit. Cras vel diam sagittis, fringilla nunc vitae, vehicula mi. Nullam et auctor mi. Proin vel pharetra tortor. Donec posuere elementum risus, et aliquet magna pharetra non. Curabitur volutpat maximus sem at euismod. Fusce porta, lacus vel varius varius, lacus felis faucibus ante, fermentum sollicitudin elit neque rhoncus tortor. Aenean eget turpis consequat, luctus lorem vehicula, ullamcorper erat."); await using var prod = StreamProducer.FromStream(new MemoryStream(seed, false)); var buffer = new MemoryStream(); await using var cons = StreamConsumer.ToStream(buffer); await prod.ConsumeAsync(cons); Assert.True(seed.SequenceEqual(buffer.ToArray())); }