public void TestActorRef_must_support_nested_Actor_creation_when_used_with_ActorRef() { var a = new TestActorRef<NestingActor>(Sys, Props.Create(() => new NestingActor(false))); Assert.NotNull(a); var nested = a.Ask<IActorRef>("any", DefaultTimeout).Result; Assert.NotNull(nested); Assert.NotSame(a, nested); }
public PersistenceActorSpec() { persistenceActorRef = ActorOfAsTestActorRef<PersistenceActor>("persistence"); PersistenceRequest req = new PersistenceRequest() { Type = PersistenceType.INIT_DATABASE }; persistenceActorRef.Tell(req); req = new PersistenceRequest() { Type = PersistenceType.OPEN }; persistenceActorRef.Tell(req); }
public MockClient(ClusterNodeContext clusterContex) { _clusterContext = clusterContex; var channel = new TestActorRef<TestActorBoundChannel>( _clusterContext.System, Props.Create(() => new TestActorBoundChannel(CreateInitialActor))); Channel = channel.UnderlyingActor; ChannelRef = channel.Cast<ActorBoundChannelRef>(); UserLogin = Channel.CreateRef<UserLoginRef>(); }
public void Setup() { var repositoryMoq = new Mock<IQuizesRepository>(); repositoryMoq .Setup(r => r.GetAllQuizes("1")) .Returns(() => new List<QuizDto> { new QuizDto { Id = 1, Name = "One" }, new QuizDto { Id = 2, Name = "Two" } }); _actor = ActorOfAsTestActorRef(() => new UserActor(repositoryMoq.Object), "1"); }
public void TestActorRef_name_must_start_with_double_dollar_sign() { //Looking at the scala code, this might not be obvious that the name starts with $$ //object TestActorRef (TestActorRef.scala) contain this code: // private[testkit] def randomName: String = { // val l = number.getAndIncrement() // "$" + akka.util.Helpers.base64(l) // } //So it adds one $. The second is added by akka.util.Helpers.base64(l) which by default //creates a StringBuilder and adds adds $. Hence, 2 $$ var testActorRef = new TestActorRef<ReplyActor>(Sys, Props.Create<ReplyActor>()); Assert.Equal(testActorRef.Path.Name.Substring(0, 2), "$$"); }
public void TestActorRef_must_support_reply_via_sender() { var serverRef = new TestActorRef<ReplyActor>(Sys, Props.Create<ReplyActor>()); var clientRef = new TestActorRef<SenderActor>(Sys, Props.Create(() => new SenderActor(serverRef))); Counter = 4; clientRef.Tell("complex"); clientRef.Tell("simple"); clientRef.Tell("simple"); clientRef.Tell("simple"); Counter.ShouldBe(0); Counter = 4; clientRef.Tell("complex2"); clientRef.Tell("simple"); clientRef.Tell("simple"); clientRef.Tell("simple"); Counter.ShouldBe(0); AssertThread(); }
protected override bool ReceiveMessage(object message) { var strMessage = message as string; switch(strMessage) { case "complexRequest": _replyTo = Sender; var worker = new TestActorRef<WorkerActor>(System, Props.Create<WorkerActor>()); worker.Tell("work"); return true; case "complexRequest2": var worker2 = new TestActorRef<WorkerActor>(System, Props.Create<WorkerActor>()); worker2.Tell(Sender, Self); return true; case "workDone": _replyTo.Tell("complexReply", Self); return true; case "simpleRequest": Sender.Tell("simpleReply", Self); return true; } return false; }
public void TestActorRef_must_proxy_receive_for_the_underlying_actor_with_sender() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); a.Receive("work", TestActor); //This will stop the actor var actorRef = (InternalTestActorRef)a.Ref; Assert.True(actorRef.IsTerminated); ExpectMsg("workDone"); }
public void TestActorRef_must_allow_override_of_dispatcher() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>().WithDispatcher("test-dispatcher1")); var actorRef = (InternalTestActorRef)a.Ref; Assert.IsType<TaskDispatcher>(actorRef.Cell.Dispatcher); }
public void TestActorRef_must_proxy_receive_for_the_underlying_actor_without_sender() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); a.Receive("work"); var actorRef = (InternalTestActorRef)a.Ref; Assert.True(actorRef.IsTerminated); }
public void TestActorRef_must_set_ReceiveTimeout_to_None() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); //TODO: When Context.ReceiveTimeout is implemented: Assert.Equal(((IInternalActor)a.UnderlyingActor).ActorContext.ReceiveTimeout, not sure what value to put here: null or Timeout.InfiniteTimeSpan); }
public void TestActorRef_must_set_CallingThreadDispatcher() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); var actorRef = (InternalTestActorRef)a.Ref; Assert.IsType<CallingThreadDispatcher>(actorRef.Cell.Dispatcher); }
public ResourceHarvesterActor_Should() { _mockScheduler = new Mock<ITellScheduler>(); _harvester = ActorOfAsTestActorRef<ResourceHarvesterActor>(Props.Create<ResourceHarvesterActor>(_mockScheduler.Object, TestActor)); }
public BossActor() { _child = TestActorRef.Create<InternalActor>(Context.System, Self, "child"); }
public void Props_must_create_actor_from_type() { var props = Props.Create<PropsTestActor>(); TestActorRef<PropsTestActor> actor = new TestActorRef<PropsTestActor>(Sys, props); Assert.IsType<PropsTestActor>(actor.UnderlyingActor); }
public VillagerActor_Should() { _villager = ActorOfAsTestActorRef<VillagerActor>(Props.Create<VillagerActor>(TestActor, _subroutinesFactory)); }
public CalculatingActorTests() { calcMock = new Mock<ICalculator>(); sut = ActorOfAsTestActorRef(() => new CalculatingActorSUT(calcMock.Object), "sut"); }
public SchedulingActorTests() { _scheduler = (TestScheduler)Sys.Scheduler; _schedulingActor = ActorOfAsTestActorRef(() => new SchedulingActor(_scheduler)); }
public void BeforeScenario() { _resourcesSupervisor = ActorOfAsTestActorRef<ResourcesSupervisorActor>(); }
public void TestActorRef_must_set_ReceiveTimeout_to_None() { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); ((IInternalActor)a.UnderlyingActor).ActorContext.ReceiveTimeout.ShouldBe(null); }
public void TestActorRef_must_allow_access_to_internals() { var actorRef = new TestActorRef<SaveStringActor>(Sys, Props.Create<SaveStringActor>()); actorRef.Tell("Hejsan!"); var actor = actorRef.UnderlyingActor; Assert.Equal("Hejsan!", actor.ReceivedString); }
public void TestActorRef_must_stop_when_sent_a_PoisonPill() { //TODO: Should have this surrounding all code EventFilter[ActorKilledException]() intercept { var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>(), null, "will-be-killed"); Sys.ActorOf(Props.Create(() => new WatchAndForwardActor(a, TestActor)), "forwarder"); a.Tell(PoisonPill.Instance); ExpectMsg<WrappedTerminated>(w => w.Terminated.ActorRef == a, TimeSpan.FromSeconds(10), string.Format("that the terminated actor was the one killed, i.e. {0}", a.Path)); var actorRef = (InternalTestActorRef)a.Ref; actorRef.IsTerminated.ShouldBe(true); AssertThread(); }
public void GivenIHaveAVillager() { var props = Props.Create<VillagerActor>(_resourcesSupervisor, _subroutinesFactory); _villagerActor = ActorOfAsTestActorRef<VillagerActor>(props); }
public void TestActorRef_must_restart_when_killed() { //TODO: Should have this surrounding all code EventFilter[ActorKilledException]() intercept { Counter = 2; var boss = new TestActorRef<BossActor>(Sys, Props.Create<BossActor>()); boss.Tell("sendKill"); Assert.Equal(0, Counter); AssertThread(); }
public void TestActorRef_must_support_futures() { var worker = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>()); var task = worker.Ask("work"); Assert.True(task.IsCompleted, "Task should be completed"); if(!task.Wait(DefaultTimeout)) XAssert.Fail("Timed out"); //Using a timeout to stop the test if there is something wrong with the code Assert.Equal("workDone", task.Result); }
public BossActor() { _child = new TestActorRef<InternalActor>(Context.System, Props.Create<InternalActor>(), Self, "child"); }
public TestSetup(TestKitBase kit, bool pullMode) { _kit = kit; _pullMode = pullMode; _handler = kit.CreateTestProbe(); _handlerRef = _handler.Ref; _bindCommander = kit.CreateTestProbe(); _parent = kit.CreateTestProbe(); _selectorRouter = kit.CreateTestProbe(); _endpoint = TestUtils.TemporaryServerAddress(); _registerCallReceiver = kit.CreateTestProbe(); _interestCallReceiver = kit.CreateTestProbe(); _parentRef = new TestActorRef<ListenerParent>(kit.Sys, Props.Create(() => new ListenerParent(this, pullMode))); }