示例#1
0
 public System.IO.Stream Create <TItem, TContext>(
     Func <System.IO.Stream, TContext> contextFactory,
     Action <TContext> dispose,
     IEnumerable <TItem> sequence,
     ArrayPool <byte> pool,
     Action <TContext, TItem> write)
 => new Stream(
     fixture.Create(contextFactory, dispose, sequence, pool, write),
     new Random(Guid.NewGuid().GetHashCode())
     );
示例#2
0
 public static Stream Create <TItem, TContext>(
     this IStreamFixture streamFixture,
     Func <Stream, TContext> contextFactory,
     IEnumerable <TItem> sequence,
     Action <TContext, TItem> write) where TContext : IDisposable
 => streamFixture.Create(
     contextFactory,
     context => context.Dispose(),
     sequence,
     ArrayPool <byte> .Shared,
     write
     );
        public void Pass_Items_In_Sequence_Order()
        {
            var write = Substitute.For <Action <StreamWriter, string> >();

            using var stream = fixture.Create(
                      output => new StreamWriter(output, Encoding.UTF8),
                      new[] { "Dog", "Cat", "Sparrow" },
                      write
                      );

            using var reader = new StreamReader(stream, Encoding.UTF8);
            reader.ReadToEnd();

            Received.InOrder(
                () =>
            {
                write(Arg.Any <StreamWriter>(), "Dog");
                write(Arg.Any <StreamWriter>(), "Cat");
                write(Arg.Any <StreamWriter>(), "Sparrow");
            }
                );
        }