public void Outgoing_TCP_stream_must_handle_when_connection_actor_terminates_unexpectedly()
{
var system2 = ActorSystem.Create("system2");
var mat2 = ActorMaterializer.Create(system2);
var serverAddress = TestUtils.TemporaryServerAddress();
var binding = system2.TcpStream()
.BindAndHandle(Flow.Create<ByteString>(), mat2, serverAddress.Address.ToString(), serverAddress.Port);
var result = Source.Maybe<ByteString>()
.Via(system2.TcpStream().OutgoingConnection(serverAddress))
.RunAggregate(0, (i, s) => i + s.Count, mat2);
// Getting rid of existing connection actors by using a blunt instrument
system2.ActorSelection(system2.Tcp().Path/"selectors"/"$b"/"*").Tell(Kill.Instance);
result.Invoking(r => r.Wait(TimeSpan.FromSeconds(3))).ShouldThrow<StreamTcpException>();
binding.Result.Unbind().Wait();
system2.Terminate().Wait();
}