public static void TestContractB_2(string CONF_SRC) { var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new ServiceBaseApplication(null, conf.Root)) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName("cs").Value); var person = new PersonData { ID = 10, FirstName = "Joe", LastName = "Tester" }; cl.SetPersonOfTheDay(person); var ret = cl.GetPersonOfTheDay(); Assert.AreEqual(10, ret.ID); Assert.AreEqual("Joe", ret.FirstName); Assert.AreEqual("Tester", ret.LastName); var sum = cl.SummarizeAndFinish(); //destructor Assert.AreEqual("That is all! for the person Tester", sum); cl.ForgetRemoteInstance(); Assert.AreEqual("Felix", cl.GetName()); //this will allocate the new isntance sum = cl.SummarizeAndFinish(); // this will kill the instance again Assert.AreEqual("That is all! but no person of the day was set", sum); dumpBindingTransports(cl.Binding); } }
public static void TestContractB_4(string CONF_SRC) { var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new ServiceBaseApplication(null, conf.Root)) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName("cs").Value); //Testing overloaded calls Assert.AreEqual("Felix", cl.GetName()); Assert.AreEqual("Felix23", cl.GetName(23)); Assert.AreEqual("Felix42", cl.GetName(42)); Assert.AreEqual("Felix", cl.GetName()); dumpBindingTransports(cl.Binding); } }
public static void TestContractB_4_Parallel_ManyClients(string CONF_SRC, bool threadSafe) { const int CNT = 10000; const int CLCNT = 157; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new ServiceBaseApplication(null, conf.Root)) { var rnd = new Random(); var rndBound = (int)(CLCNT * 1.3751d); var clients = new List <TestContractBClient>(); for (var i = 0; i < CLCNT; i++) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName(threadSafe?"cs":"cs2").Value); Assert.AreEqual("Felix1223", cl.GetName(1223));//alloc server clients.Add(cl); } var set = new HashSet <int>(); var watch = System.Diagnostics.Stopwatch.StartNew(); //.....for making many parallel calls System.Threading.Tasks.Parallel.For(0, CNT, (i, loop) => { var id = System.Threading.Thread.CurrentThread.ManagedThreadId; lock (set) set.Add(id); var idx = rnd.Next(rndBound); if (idx >= clients.Count) { idx = clients.Count - 1; } var cl = clients[idx]; //Testing overloaded calls Assert.AreEqual("Felix{0}".Args(i), cl.GetName(i)); }); var elps = watch.ElapsedMilliseconds; Console.WriteLine("Parallel Many Clients Glue test made {0} calls in {1} ms at {2} call/sec and was done by these threads:".Args(CNT, elps, CNT / (elps / 1000d))); dumpBindingTransports(App.Glue.Bindings.First()); var cnt = 0; foreach (var id in set) { Console.Write(id + ", "); cnt++; } Console.WriteLine(cnt + " total"); } }
public static void TestContractB_4_Parallel(string CONF_SRC, bool threadSafe) { const int CNT = 10000; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using (var app = new ServiceBaseApplication(null, conf.Root)) { //Use the same client..... var cl = new TestContractBClient(App.ConfigRoot.AttrByName(threadSafe?"cs":"cs2").Value); Assert.AreEqual("Felix1223", cl.GetName(1223)); //alloc server var set = new HashSet <int>(); var watch = System.Diagnostics.Stopwatch.StartNew(); //.....for making many parallel calls System.Threading.Tasks.Parallel.For(0, CNT, (i, loop) => { var id = System.Threading.Thread.CurrentThread.ManagedThreadId; lock (set) set.Add(id); //Testing overloaded calls var result = cl.GetName(i); Assert.AreEqual("Felix{0}".Args(i), result); }); var elps = watch.ElapsedMilliseconds; Console.WriteLine("Parallel Glue Test made {0} calls in {1} ms at {2} call/sec and was done by these threads:".Args(CNT, elps, CNT / (elps / 1000d))); dumpBindingTransports(cl.Binding); var cnt = 0; foreach (var id in set) { Console.Write(id + ", "); cnt++; } Console.WriteLine(cnt + " total"); } }
public static void TestContractB_4_Parallel_ManyClients(string CONF_SRC, bool threadSafe) { const int CNT = 10000; const int CLCNT = 157; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using( var app = new ServiceBaseApplication(null, conf.Root)) { var rnd = new Random(); var rndBound = (int)(CLCNT * 1.3751d); var clients = new List<TestContractBClient>(); for(var i=0; i<CLCNT; i++) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName(threadSafe?"cs":"cs2").Value); Assert.AreEqual( "Felix1223", cl.GetName(1223));//alloc server clients.Add(cl); } var set = new HashSet<int>(); var watch = System.Diagnostics.Stopwatch.StartNew(); //.....for making many parallel calls System.Threading.Tasks.Parallel.For(0, CNT, (i, loop)=> { var id = System.Threading.Thread.CurrentThread.ManagedThreadId; lock(set) set.Add( id ); var idx = rnd.Next( rndBound ); if (idx>=clients.Count) idx = clients.Count-1; var cl = clients[idx]; //Testing overloaded calls Assert.AreEqual( "Felix{0}".Args(i), cl.GetName(i)); }); var elps = watch.ElapsedMilliseconds; Console.WriteLine("Parallel Many Clients Glue test made {0} calls in {1} ms at {2} call/sec and was done by these threads:".Args(CNT, elps, CNT / (elps / 1000d)) ); dumpBindingTransports( App.Glue.Bindings.First() ); var cnt = 0; foreach(var id in set) { Console.Write( id+", " ); cnt++; } Console.WriteLine( cnt + " total"); } }
public static void TestContractB_4_Parallel(string CONF_SRC, bool threadSafe) { const int CNT = 10000; var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using( var app = new ServiceBaseApplication(null, conf.Root)) { //Use the same client..... var cl = new TestContractBClient(App.ConfigRoot.AttrByName(threadSafe?"cs":"cs2").Value); Assert.AreEqual( "Felix1223", cl.GetName(1223));//alloc server var set = new HashSet<int>(); var watch = System.Diagnostics.Stopwatch.StartNew(); //.....for making many parallel calls System.Threading.Tasks.Parallel.For(0, CNT, (i, loop)=> { var id = System.Threading.Thread.CurrentThread.ManagedThreadId; lock(set) set.Add( id ); //Testing overloaded calls var result = cl.GetName(i); Assert.AreEqual( "Felix{0}".Args(i), result); }); var elps = watch.ElapsedMilliseconds; Console.WriteLine("Parallel Glue Test made {0} calls in {1} ms at {2} call/sec and was done by these threads:".Args(CNT, elps, CNT / (elps / 1000d)) ); dumpBindingTransports( cl.Binding ); var cnt = 0; foreach(var id in set) { Console.Write( id+", " ); cnt++; } Console.WriteLine( cnt + " total"); } }
public static void TestContractB_4_Async(string CONF_SRC) { var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using( var app = new ServiceBaseApplication(null, conf.Root)) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName("cs").Value); Assert.AreEqual( "Felix", cl.GetName());//alloc first //Testing overloaded calls via CallSlot Assert.AreEqual( "Felix", cl.Async_GetName() .GetValue<string>()); Assert.AreEqual( "Felix23", cl.Async_GetName(23).GetValue<string>()); Assert.AreEqual( "Felix42", cl.Async_GetName(42).GetValue<string>()); Assert.AreEqual( "Felix", cl.Async_GetName() .GetValue<string>()); dumpBindingTransports( cl.Binding ); } }
public static void TestContractB_3(string CONF_SRC) { var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using( var app = new ServiceBaseApplication(null, conf.Root)) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName("cs").Value); Assert.AreEqual( "Felix", cl.GetName()); dumpBindingTransports( cl.Binding ); } }
public static void TestContractB_2(string CONF_SRC) { var conf = LaconicConfiguration.CreateFromString(CONF_SRC); using( var app = new ServiceBaseApplication(null, conf.Root)) { var cl = new TestContractBClient(App.ConfigRoot.AttrByName("cs").Value); var person = new PersonData{ID = 10, FirstName="Joe", LastName="Tester" }; cl.SetPersonOfTheDay( person ); var ret = cl.GetPersonOfTheDay(); Assert.AreEqual( 10, ret.ID); Assert.AreEqual( "Joe", ret.FirstName); Assert.AreEqual( "Tester", ret.LastName); var sum = cl.SummarizeAndFinish(); //destructor Assert.AreEqual("That is all! for the person Tester", sum); cl.ForgetRemoteInstance(); Assert.AreEqual("Felix", cl.GetName()); //this will allocate the new isntance sum = cl.SummarizeAndFinish(); // this will kill the instance again Assert.AreEqual("That is all! but no person of the day was set", sum); dumpBindingTransports( cl.Binding ); } }