public void AgentSupplyGpiTest() { IGpiA retGpiA = null; Regulus.Serialization.ISerializer serializer = new Regulus.Serialization.Dynamic.Serializer(); IProtocol protocol = ProtocolHelper.CreateProtocol(serializer); Stream cdClient = new Regulus.Remote.Standalone.Stream(); Network.IStreamable peerClient = cdClient; PackageWriter <ResponsePackage> writer = new PackageWriter <ResponsePackage>(serializer); writer.Start(new ReverseStream(cdClient)); Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol) as Ghost.IAgent; agent.QueryNotifier <IGpiA>().Supply += gpi => retGpiA = gpi; agent.Start(peerClient); writer.ServerToClient(serializer, ServerToClientOpCode.LoadSoul, new Regulus.Remote.PackageLoadSoul() { EntityId = 1, ReturnType = false, TypeId = 1 }); writer.ServerToClient(serializer, ServerToClientOpCode.LoadSoulCompile, new Regulus.Remote.PackageLoadSoulCompile() { EntityId = 1, TypeId = 1, ReturnId = 0, PassageId = 0 }); while (retGpiA == null) { agent.Update(); } agent.Stop(); writer.Stop(); Assert.AreNotEqual(null, retGpiA); }
private static void _TestService(IBinderProvider entry, ref bool bind, IProtocol protocol) { bind = false; var service = Regulus.Remote.Standalone.Provider.CreateService(protocol, entry); Ghost.IAgent agent = new Regulus.Remote.Ghost.Agent(protocol); service.Join(agent, null); IGpiA retGpiA = null; bool ret = false; agent.QueryNotifier <IGpiA>().Supply += gpi => { ret = true; retGpiA = gpi; }; var timer = new Regulus.Utility.TimeCounter(); var apr = new Regulus.Utility.AutoPowerRegulator(new Utility.PowerRegulator()); while (retGpiA == null) { apr.Operate(); agent.Update(); if (timer.Second > 10) { throw new System.Exception($"debug agent:{agent.Active} bind:{bind} "); } } service.Leave(agent); service.Dispose(); Assert.AreNotEqual(null, retGpiA); Assert.AreEqual(true, bind); Assert.AreEqual(true, ret); }