public TestProbeParentActor( ITestProbeCreator testProbeCreator, IWaiter exceptionWaiter, TestKitBase testKit, Func <Exception, Directive> decider, IReadOnlyDictionary <Type, Func <object, object> > handlers) { _exceptionWaiter = exceptionWaiter; _decider = decider; _unhandledExceptions = new List <Exception>(); TestProbe = testProbeCreator.Create(testKit); TestProbe.SetAutoPilot(new DelegateAutoPilot((_, message) => { Type messageType = message.GetType(); if (handlers.TryGetValue(messageType, out Func <object, object> handler)) { object reply = handler(message); Context.Sender.Tell(reply); } return(AutoPilot.KeepRunning); })); ReceiveAny(o => TestProbe.Forward(o)); Ref = Self; }
public TestProbeChildActor(ITestProbeCreator testProbeCreator, TestKitBase testKit, IReadOnlyDictionary <Type, Func <object, object> > handlers = null) { ActorPath = Context.Self.Path; TestProbe = testProbeCreator.Create(testKit); PropsSupervisorStrategy = Context.Props.SupervisorStrategy; ReceiveAny(o => TestProbe.Forward(o)); if (handlers != null) { TestProbe.SetAutoPilot(new DelegateAutoPilot((sender, message) => { Type messageType = message.GetType(); if (handlers.TryGetValue(messageType, out Func <object, object> handler)) { object reply = handler(message); Context.Sender.Tell(reply); } return(AutoPilot.KeepRunning); })); } }