public void TestShardRun() { TestLauncherActor.Test(() => { ActorServer.Start(ActorConfigManager.CastForTest()); new ShardDirectoryClientTest(); }); }
public void DiscoTest() { TestLauncherActor.Test(() => { ActorServer.Start(ActorConfigManager.CastForTest()); var act = new DiscoTestActor(fLauncher); DirectoryActor.GetDirectory().Disco(act); } ); }
public void ParserActorTest() { TestLauncherActor.Test(() => { ActorServer.Start(ActorConfigManager.CastForTest()); var parserTest = new ParserTest(); var receiver = new TestReceiver(); parserTest.SendMessage((IActor)receiver); var future = receiver.GetResult().Result(); Assert.IsTrue(future.Any()); Assert.IsTrue(future.Contains("Max")); }); }
public void TestSerializeActor() { TestLauncherActor.Test(() => { ActorServer.Start(ActorConfigManager.CastForTest()); var tst1 = new Test1() { Name = "TestName1" }; var tst2 = new Test1() { Name = "TestName2" }; var lst = new List <IActor> { tst1, tst2 }; // serialize BaseActor actor = new BaseActor(); SerialObject so = new SerialObject(lst, actor.Tag); NetDataContractSerializer dcs = new NetDataContractSerializer() { SurrogateSelector = new ActorSurrogatorSelector(), Binder = new ActorBinder() }; using (MemoryStream ms = new MemoryStream()) { dcs.Serialize(ms, so); ms.Seek(0, SeekOrigin.Begin); object obj = dcs.ReadObject(ms); SerialObject soread = (SerialObject)obj; var lst2 = (List <IActor>)soread.Data; Assert.AreEqual(2, lst2.Count); var l1 = (RemoteSenderActor)(lst2[0]); var l2 = (RemoteSenderActor)(lst2.Last()); Assert.AreEqual(so.Tag.Key(), soread.Tag.Key()); Assert.AreEqual(tst1.Tag.Key(), l1.fRemoteTag.Key()); Assert.AreEqual(tst2.Tag.Key(), l2.fRemoteTag.Key()); } }, 30000); }
private void DoDiscoveryActorTest() { const string localHost = "http://localhost:80"; var uri = new Uri(localHost); ConfigurationManager.AppSettings["ListenerService"] = "MemoryListenerService"; ConfigurationManager.AppSettings["SerializeService"] = "NetDataContractSerializeService"; ActorServer.Start(ActorConfigManager.CastForTest()); var future = new Future <Dictionary <string, string> >(); new DiscoveryActor(uri.AbsoluteUri, future); var result = future.Result(60000); Assert.IsNotNull(result); Assert.IsTrue(result.Count >= 3, $"result is {result.Count}"); Assert.IsTrue(result.Keys.Contains("KnownShards")); }
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 EchoClient100Test() { GlobalContext.MessageTracerService = new MemoryMessageTracerService(); TestLauncherActor.Test(() => { ActorServer.Start(ActorConfigManager.CastForTest()); new EchoServerActor(); for (int i = 0; i < 5; i++) { EchoClientActor aClient = new EchoClientActor(); aClient.Connect("EchoServer"); aClient.SendMessage($"client-{i}"); } Task.Delay(10000).Wait(); }, 15000); var mess = GlobalContext.MessageTracerService.CopyAllMessages(); #pragma warning disable CA1827 // Do not use Count() or LongCount() when Any() can be used Assert.IsTrue(mess.Count(t => t.StartsWith("client receive", StringComparison.InvariantCulture)) >= 1); #pragma warning restore CA1827 // Do not use Count() or LongCount() when Any() can be used }
private void DoDiscoTest() { ConfigurationManager.AppSettings["ListenerService"] = "MemoryListenerService"; ConfigurationManager.AppSettings["SerializeService"] = "NetDataContractSerializeService"; ActorConfigManager config = ActorConfigManager.CastForTest(); ActorServer.Start(config); IActor actor1 = new TestHostRelayActor(); DiscoCommand disco = new DiscoCommand(actor1); RemoteSenderActor remote = new RemoteSenderActor(actor1.Tag); remote.SendMessage(disco); IFuture <IEnumerable <string> > future = new Future <IEnumerable <string> >(); actor1.SendMessage(future); var result1 = future.Result(); Assert.IsTrue(result1.Count() >= 3, $"found {result1.Count()}"); }
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)); }); }