public static async Task ASYNC_TestContractA_TwoWayCall_Timeout(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); cl.TimeoutMs = 2000; CallSlot call = null; try { call = await cl.Async_Sleeper(10000); call.GetValue <int>(); } catch (ClientCallException err) { Aver.IsTrue(CallStatus.Timeout == err.Status); return; } catch (System.IO.IOException err) //sync binding throws IO exception { Aver.IsTrue(err.Message.Contains("after a period of time")); return; } Aver.Fail("Invalid Call status: " + (call != null ? call.CallStatus.ToString() : "call==null")); } }
public static void TestContractA_TwoWayCall_Timeout(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); cl.TimeoutMs = 2000; try { cl.Sleeper(5000); } catch (ClientCallException err) { Aver.IsTrue(CallStatus.Timeout == err.Status); return; } catch (System.IO.IOException err) //sync binding throws IO exception { Aver.IsTrue(err.Message.Contains("after a period of time")); return; } Aver.Fail("Invalid Call status"); } }
public static async Task ASYNC_MANY_AWAITS_TestContractA_TwoWayCall(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); var call = cl.Async_Method1(234); var result = await call.AsTaskReturning <string>(); Aver.IsTrue(call.Available); Aver.AreEqual("234", result); Aver.AreEqual("234", (await call).GetValue <string>()); //this will instantly return as it is completed already Aver.AreEqual("234", (await call).GetValue <string>()); //so will this Aver.AreEqual("234", (await call).GetValue <string>()); //and this... and so on.... can do many awaits Aver.AreEqual(234, TestServerA.s_Accumulator); } }
public static void TestContractA_TwoWayCall(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); var result = cl.Method1(12); Aver.AreEqual("12", result); Aver.AreEqual(12, TestServerA.s_Accumulator); } }
public static async Task ASYNC_AWAIT_CALL_TestContractA_TwoWayCall(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); var call = cl.Async_Method1(12); await call;//this will wait and come back on either timeout or result delivery Aver.IsTrue(call.Available); Aver.AreEqual("12", call.GetValue <string>()); Aver.AreEqual(12, TestServerA.s_Accumulator); } }
public static async Task ASYNC_TestContractA_OneWayCall(string CONF_SRC) { TestServerA.s_Accumulator = 0; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new AzosApplication(null, conf.Root)) { var cl = new TestContractAClient(app.Glue, app.ConfigRoot.AttrByName("cs").Value); await cl.Async_Method2(93);//this should instantly return as call already dispatched //since this is one-way call, we wait 10 sec tops for server-side state becoming 93 for (var cnt = 0; cnt < 10 && TestServerA.s_Accumulator != 93; cnt++) { System.Threading.Thread.Sleep(1000); } Aver.AreEqual(93, TestServerA.s_Accumulator); } }