public async Task ActorContext_must_canonicalize_behaviors() { var probe = new TestProbe <Event>(); var behavior = Behaviors.Receive <Command>(async(context, message) => { switch (message.Type) { case Command.CommandType.Ping: probe.Ref.Tell(Event.Pong); return(Behaviors.Same <Command>()); case Command.CommandType.Miss: probe.Ref.Tell(Event.Missed); return(Behaviors.Unhandled <Command>()); case Command.CommandType.Renew: var aref = ((Command <Event>)message).Ref; aref.Tell(Event.Renewed); return(Behaviors.Same <Command>()); default: throw new Exception($"Unexpected message {message}"); } }); var actor = this.SpawnAnonymous(behavior); actor.Tell(Command.Ping); await probe.MoveNext(); probe.Current.Should().Be(Event.Pong); }
public void ActorContext_must_be_usable_from_behavior_interpret_message() { var b = Behaviors.Receive <string>(async(context, message) => { //TODO: Behavior.interpretMessage(b, context, message) return(Behaviors.Same <string>()); }); }
public ValueTask <Behavior <T> > AroundSignal <TSignalTarget>(IActorContext <T> context, ISignal signal, TSignalTarget target) { if (blackhole) { context.System.EventStream.Publish(new Dropped(signal, context.Self.UnsafeCast <Nothing>())); return(new ValueTask <Behavior <T> >(Behaviors.Same <T>())); } else { return(target.Apply(context, signal)); } }
public AskSpec(ITestOutputHelper output) : base(output) { this.behavior = Behaviors.Receive <Msg>(async(ctx, msg) => { switch (msg.Type) { case MessageType.Foo: msg.ReplyTo.Tell("foo"); return(Behaviors.Same <Msg>()); case MessageType.Stop: msg.ReplyTo.Tell("stopped"); return(Behaviors.Stopped <Msg>()); default: throw new NotImplementedException(); } ; }); }