public void CreateActorRefUsingActorAndSendThreeMessages() { int total = 0; EventWaitHandle wait = new AutoResetEvent(false); Actor actor = new LambdaActor(c => { total += (int)c; if (total >= 6) { wait.Set(); } }); ActorSystem system = new ActorSystem(); var result = system.ActorOf(actor); Assert.IsNotNull(result); Assert.AreSame(result, actor.Self); result.Tell(1); result.Tell(2); result.Tell(3); wait.WaitOne(); Assert.AreEqual(6, total); system.Stop(result); // TODO better time management Thread.Sleep(1000); Assert.AreEqual(ActorState.Stopped, actor.State); }
public void SendOneMessage() { int total = 0; Actor actor = new LambdaActor(c => { total += (int)c; }); actor.Receive(1); Assert.AreEqual(1, total); }
public void SendThreeMessages() { int total = 0; Actor actor = new LambdaActor(c => { total += (int)c; }); actor.Receive(1); actor.Receive(2); actor.Receive(3); Assert.AreEqual(6, total); }
public void CreateAndUseForwardActor() { int total = 0; EventWaitHandle wait = new AutoResetEvent(false); Actor actor = new LambdaActor(c => { total += (int)c; wait.Set(); }); ActorSystem system = new ActorSystem(); var actorref = system.ActorOf(actor); Actor forwarder = new ForwardActor(actorref); forwarder.Receive(1); wait.WaitOne(); Assert.AreEqual(1, total); }