コード例 #1
0
 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);
 }
コード例 #2
0
        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);

        }
コード例 #3
0
ファイル: MockClient.cs プロジェクト: SaladLab/TicTacToe
        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>();
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        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), "$$");
        }
コード例 #6
0
        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();
        }
コード例 #7
0
ファイル: ReplyActor.cs プロジェクト: njannink/sonarlint-vs
 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;
 }
コード例 #8
0
 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");
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 public ResourceHarvesterActor_Should()
 {
     _mockScheduler = new Mock<ITellScheduler>();
     _harvester = ActorOfAsTestActorRef<ResourceHarvesterActor>(Props.Create<ResourceHarvesterActor>(_mockScheduler.Object, TestActor));
 }
コード例 #14
0
ファイル: BossActor.cs プロジェクト: ClusterReply/akka.net
 public BossActor()
 {
     _child = TestActorRef.Create<InternalActor>(Context.System, Self, "child");
 }
コード例 #15
0
ファイル: PropsSpec.cs プロジェクト: rodrigovidal/akka.net
 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);
 }
コード例 #16
0
 public VillagerActor_Should()
 {
     _villager = ActorOfAsTestActorRef<VillagerActor>(Props.Create<VillagerActor>(TestActor, _subroutinesFactory));
 }
コード例 #17
0
 public CalculatingActorTests()
 {
     calcMock = new Mock<ICalculator>();
     sut = ActorOfAsTestActorRef(() => new CalculatingActorSUT(calcMock.Object), "sut");
 }
コード例 #18
0
 public SchedulingActorTests()
 {
     _scheduler = (TestScheduler)Sys.Scheduler;
     _schedulingActor = ActorOfAsTestActorRef(() => new SchedulingActor(_scheduler));
 }
コード例 #19
0
 public void BeforeScenario()
 {
     _resourcesSupervisor = ActorOfAsTestActorRef<ResourcesSupervisorActor>();
 }
コード例 #20
0
 public void TestActorRef_must_set_ReceiveTimeout_to_None()
 {
     var a = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>());
     ((IInternalActor)a.UnderlyingActor).ActorContext.ReceiveTimeout.ShouldBe(null);
 }
コード例 #21
0
 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);
 }
コード例 #22
0
 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();
 }
コード例 #23
0
 public void GivenIHaveAVillager()
 {
     var props = Props.Create<VillagerActor>(_resourcesSupervisor, _subroutinesFactory);
     _villagerActor = ActorOfAsTestActorRef<VillagerActor>(props);
 }
コード例 #24
0
        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();
        }
コード例 #25
0
 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);
 }
コード例 #26
0
ファイル: BossActor.cs プロジェクト: njannink/sonarlint-vs
 public BossActor()
 {
     _child = new TestActorRef<InternalActor>(Context.System, Props.Create<InternalActor>(), Self, "child");
 }
コード例 #27
0
ファイル: TcpListenerSpec.cs プロジェクト: njimenez/akka.net
            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)));
            }