Akka.Streams.Tests.IO.TcpSpec.Tcp_listen_stream_must_work_with_a_chain_of_echoes C# (CSharp) Method

Tcp_listen_stream_must_work_with_a_chain_of_echoes() private method

        public void Tcp_listen_stream_must_work_with_a_chain_of_echoes()
        {
            var serverAddress = TestUtils.TemporaryServerAddress();
            var t = Sys.TcpStream()
                .Bind(serverAddress.Address.ToString(), serverAddress.Port)
                .ToMaterialized(EchoHandler(), Keep.Both)
                .Run(Materializer);
            var bindingFuture = t.Item1;
            var echoServerFinish = t.Item2;
            
            // make sure that the server has bound to the socket
            bindingFuture.Wait(100).Should().BeTrue();
            var binding = bindingFuture.Result;

            var echoConnection = Sys.TcpStream().OutgoingConnection(serverAddress);

            var testInput = Enumerable.Range(0, 255).Select(i => ByteString.Create(new[] { Convert.ToByte(i) })).ToList();
            var expectedOutput = testInput.Aggregate(ByteString.Empty, (agg, b) => agg.Concat(b));

            var resultFuture = Source.From(testInput)
                .Via(echoConnection) // The echoConnection is reusable
                .Via(echoConnection)
                .Via(echoConnection)
                .Via(echoConnection)
                .RunAggregate(ByteString.Empty, (agg, b) => agg.Concat(b), Materializer);

            resultFuture.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
            resultFuture.Result.ShouldBeEquivalentTo(expectedOutput);
            binding.Unbind().Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
            echoServerFinish.Wait(TimeSpan.FromSeconds(1)).Should().BeTrue();
        }