Akka.Streams.Tests.IO.FileSinkSpec.SynchronousFileSink_should_allow_appending_to_file C# (CSharp) Méthode

SynchronousFileSink_should_allow_appending_to_file() private méthode

private SynchronousFileSink_should_allow_appending_to_file ( ) : void
Résultat void
        public void SynchronousFileSink_should_allow_appending_to_file()
        {
            this.AssertAllStagesStopped(() =>
            {
                TargetFile(f =>
                {
                    Func<List<string>, Task<IOResult>> write = lines => Source.From(lines)
                        .Select(ByteString.FromString)
                        .RunWith(FileIO.ToFile(f, fileMode: FileMode.Append), _materializer);

                    var completion1 = write(_testLines);
                    completion1.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
                    var result1 = completion1.Result;

                    var lastWrite = new List<string>();
                    for (var i = 0; i < 100; i++)
                        lastWrite.Add("x");

                    var completion2 = write(lastWrite);
                    completion2.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
                    var result2 = completion2.Result;

                    var lastWriteString = new string(lastWrite.SelectMany(x => x).ToArray());
                    var testLinesString = new string(_testLines.SelectMany(x => x).ToArray());

                    f.Length.Should().Be(result1.Count + result2.Count);

                    //NOTE: no new line at the end of the file - does JVM/linux appends new line at the end of the file in append mode?
                    CheckFileContent(f, testLinesString + lastWriteString);
                });
            }, _materializer);
        }