async Task Run(MyFlags flags, Type expectedException = null, ClientAndServerParameters parameters = null, Action <ClientAndServer> action = null) { if (parameters == null) { parameters = GetDefaultParameters(); } try { if (Configuration.EnableDebugging) { parameters.EnableDebugging = true; } using (var connection = (ClientAndServer)await Factory.Start(parameters)) { if (action != null) { action(connection); } var handler = new MyConnectionHandler(connection, flags); await handler.Run(); } if (expectedException != null) { Assert.Fail("Expected an exception of type {0}", expectedException); } } catch (Exception ex) { if (expectedException != null) { Assert.That(ex, Is.InstanceOf(expectedException)); } else { DebugHelper.WriteLine("ERROR: {0} {1}", ex.GetType(), ex); throw; } } }
async Task Run (MyFlags flags, Type expectedException = null, ClientAndServerParameters parameters = null, Action<ClientAndServer> action = null) { if (parameters == null) parameters = GetDefaultParameters (); try { if (Configuration.EnableDebugging) parameters.EnableDebugging = true; using (var connection = (ClientAndServer)await Factory.Start (parameters)) { if (action != null) action (connection); var handler = new MyConnectionHandler (connection, flags); await handler.Run (); } if (expectedException != null) Assert.Fail ("Expected an exception of type {0}", expectedException); } catch (Exception ex) { if (expectedException != null) { Assert.That (ex, Is.InstanceOf (expectedException)); } else { DebugHelper.WriteLine ("ERROR: {0} {1}", ex.GetType (), ex); throw; } } }