public CalcFormModel(Form1 aForm) { Form = aForm; CalcActor = new CalcActor(); _observer = new StateFullActor <Accumulators>(); CalcActor.Register(_observer); }
public void ActorStateTest() { TestLauncherActor.Test( () => { var stateActor = new StateFullActor <string>(); string strTest = "Test actStateFullActor"; stateActor.Set(strTest); Assert.AreEqual(strTest, stateActor.Get()); }); }
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); }); }
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)); }); }
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)); }); }