public static void Test() { var system = new ActorSystem(); var pingPong = new CountdownEvent(PingPongCount); var bruce = new Bruce(pingPong); var lee = new Lee(pingPong); system.Add(bruce, ctx => { ctx.Actor.Bus = ctx.Bus; }); system.Add(lee, ctx => { ctx.Actor.Bus = ctx.Bus; }); var c = system.Start(); var p = new Pong(); c.Publish(ref p); var ended = pingPong.Wait(TimeSpan.FromSeconds(10)); c.Stop(); Assert.True(ended, "Bruce/Lee didn't ping/pong"); }
public void WhenExceptionActionPassed_ThenItShouldBeInvokedOnException() { var system = new ActorSystem(); IBus bus = null; system.Add(new ThrowingHandler(), ctx => { bus = ctx.Bus; }); Exception ex = null; var wait = new ManualResetEventSlim(false); system.Start(e => { ex = e; wait.Set(); }); var msg = new Message(); bus.Publish(ref msg); Assert.True(wait.Wait(TimeSpan.FromSeconds(10))); ExceptionHelpers.ExceptionOrAggregateWithOne(ex, ThrowingHandler.Exception); }