Akka.Streams.Tests.IO.FileSourceSpec.FileSource_should_read_contents_from_a_file C# (CSharp) Method

FileSource_should_read_contents_from_a_file() private method

private FileSource_should_read_contents_from_a_file ( ) : void
return void
        public void FileSource_should_read_contents_from_a_file()
        {
            this.AssertAllStagesStopped(() =>
            {
                var chunkSize = 512;
                var bufferAttributes = Attributes.CreateInputBuffer(1, 2);

                var p = FileIO.FromFile(TestFile(), chunkSize)
                    .WithAttributes(bufferAttributes)
                    .RunWith(Sink.AsPublisher<ByteString>(false), _materializer);

                var c = this.CreateManualProbe<ByteString>();
                p.Subscribe(c);
                var sub = c.ExpectSubscription();

                var remaining = _testText;
                var nextChunk = new Func<string>(() =>
                {
                    string chunks;

                    if (remaining.Length <= chunkSize)
                    {
                        chunks = remaining;
                        remaining = string.Empty;
                    }
                    else
                    {
                        chunks = remaining.Substring(0, chunkSize);
                        remaining = remaining.Substring(chunkSize);
                    }

                    return chunks;
                });

                sub.Request(1);
                c.ExpectNext().DecodeString(Encoding.UTF8).Should().Be(nextChunk());
                sub.Request(1);
                c.ExpectNext().DecodeString(Encoding.UTF8).Should().Be(nextChunk());
                c.ExpectNoMsg(TimeSpan.FromMilliseconds(300));

                sub.Request(200);
                var expectedChunk = nextChunk();
                while (!string.IsNullOrEmpty(expectedChunk))
                {
                    var actual = c.ExpectNext().DecodeString(Encoding.UTF8);
                    actual.Should().Be(expectedChunk);
                    expectedChunk = nextChunk();
                }
                sub.Request(1);
                c.ExpectComplete();
            }, _materializer);
        }