예제 #1
0
        public void ShouldNotBeAbleToSendMessageFromTranscientActorToRemote()
        {
            IActor actorFactory() => new HelloActorHandleCommand();

            var configuration1 = new RootRemoteConfiguration("http://127.0.0.1:8080");

            var world1  = World.Create <TestRegistry>(configuration1);
            var world2  = World.Create <TestRegistry>();
            var process = world1.Spawn(actorFactory, "http://127.0.0.1:8181");

            //send form world2 (transcient) to world1 first spawn (remote)
            Assert.ThrowsAsync <Exception>(async() =>
            {
                await world2.Send <DoSayHello>("http://127.0.0.1:8181", new SayHello(process.Configuration.Id.Value));
            });


            world1.Dispose();
            world2.Dispose();
        }
예제 #2
0
        public async Task ShouldExecuteCommandFromWorld()
        {
            IActor actorFactory() => new HelloActorHandleCommand();

            var configuration1 = new RootRemoteConfiguration("http://127.0.0.1:8080");
            var configuration2 = new RootRemoteConfiguration("http://127.0.0.1:8181");

            var world1  = World.Create <TestRegistry>(configuration1);
            var world2  = World.Create <TestRegistry>(configuration2);
            var process = world1.Spawn(actorFactory, "http://127.0.0.1:8282");

            //send from worl2 to world1 first spawn
            var commandResult = await world2.Send <DoSayHello>("http://127.0.0.1:8282", new SayHello(process.Configuration.Id.Value), TimeSpan.FromSeconds(2));

            await Task.Delay(10);

            Assert.AreEqual("ok", commandResult.Who);

            world1.Dispose();
            world2.Dispose();
        }