public void GetStatTest()
        {
            var stat = HostDirectoryActor.GetInstance().GetStat();

            Assert.IsNotNull(stat);
            Assert.IsTrue(stat.Contains("Host entries"));
        }
Exemplo n.º 2
0
 public RPrint()
     : base()
 {
     DirectoryActor.GetDirectory().Register(this, "RPrint");
     HostDirectoryActor.Register(this);
     Become(new Behavior <string>(DoRPrint));
 }
        public void RegisterUnregisterTestV2()
        {
            TestLauncherActor.Test(() =>
            {
                ConfigurationManager.AppSettings["ListenerService"]  = "MemoryListenerService";
                ConfigurationManager.AppSettings["SerializeService"] = "NetDataContractSerializeService";
                ActorServer.Start("localhost", 80, new HostRelayActor());
                var actor = new StateFullActor <string>();
                HostDirectoryActor.Register(actor);
                Task.Delay(5000).Wait();
                var stat = HostDirectoryActor.GetInstance().GetEntries();
                Assert.IsTrue(stat.Count(t => t == actor.Tag.Key()) == 1);

                HostDirectoryActor.Unregister(actor);
                Task.Delay(5000).Wait();
                var stat2 = HostDirectoryActor.GetInstance().GetEntries();
                Assert.IsTrue(stat2.Count(t => t == actor.Tag.Key()) == 0);
            });
        }
Exemplo n.º 4
0
        public void RegisterUnregisterTestV2()
        {
            TestLauncherActor.Test(() =>
            {
                ActorServer.Start(ActorConfigManager.CastForTest());
                var actor = new StateFullActor <string>();

                HostDirectoryActor.Register(actor);
                Task.Delay(5000).Wait();
                var stat = HostDirectoryActor.GetInstance().GetEntries();
                Assert.IsTrue(stat.Count(t => t == actor.Tag.Key()) == 1);

                HostDirectoryActor.Unregister(actor);
                Task.Delay(5000).Wait();
                var stat2 = HostDirectoryActor.GetInstance().GetEntries();
#pragma warning disable CA1827                                              // Do not use Count() or LongCount() when Any() can be used
                Assert.IsTrue(stat2.Count(t => t == actor.Tag.Key()) == 0); // don't touch
#pragma warning restore CA1827                                              // Do not use Count() or LongCount() when Any() can be used
            });
        }
        public void RegisterUnregisterTest()
        {
            TestLauncherActor.Test(() =>
            {
                ConfigurationManager.AppSettings["ListenerService"]  = "MemoryListenerService";
                ConfigurationManager.AppSettings["SerializeService"] = "NetDataContractSerializeService";
                ActorServer.Start("localhost", 80, new HostRelayActor());
                var actor = new StateFullActor <string>();
                HostDirectoryActor.Register(actor);
                SerialObject so = new SerialObject(new MessageParam <StateAction, string>(StateAction.Set, "Test"), actor.Tag);
                HostDirectoryActor.GetInstance().SendMessage(so);
                var result = actor.GetAsync(10000).Result;
                Assert.AreEqual(result, "Test");

                HostDirectoryActor.Unregister(actor);
                SerialObject so2 = new SerialObject(new MessageParam <StateAction, string>(StateAction.Set, "Test2"), actor.Tag);
                HostDirectoryActor.GetInstance().SendMessage(so2);
                var result2 = actor.GetAsync(10000).Result;
                Assert.AreEqual("Test", result2, string.Format(CultureInfo.InvariantCulture, "Expected {0} Found {1}", "Test", result2));
            });
        }
Exemplo n.º 6
0
        public void RegisterUnregisterTest()
        {
            TestLauncherActor.Test(() =>
            {
                ActorServer.Start(ActorConfigManager.CastForTest());
                var actor = new StateFullActor <string>();
                HostDirectoryActor.Register(actor);
                SerialObject so = new SerialObject(new MessageParam <StateAction, string>(StateAction.Set, "Test"), actor.Tag);
                HostDirectoryActor.GetInstance().SendMessage(so);
                Task.Delay(5000).Wait();
                var result = actor.GetStateAsync(5000).Result;
                Assert.AreEqual(result, "Test");

                HostDirectoryActor.Unregister(actor);
                SerialObject so2 = new SerialObject(new MessageParam <StateAction, string>(StateAction.Set, "Test2"), actor.Tag);
                HostDirectoryActor.GetInstance().SendMessage(so2);
                Task.Delay(5000).Wait();
                var result2 = actor.GetStateAsync(5000).Result;
                Assert.AreEqual("Test", result2, string.Format(CultureInfo.InvariantCulture, "Expected {0} Found {1}", "Test", result2));
            });
        }