public void testBackgroundJob() { Worker w = new Worker("localhost"); w.registerFunction("bgtest", bgtest); w.workLoop(); Client c = new Client("localhost"); byte[] data = new ASCIIEncoding().GetBytes(""); string jobhandle = c.submitJobInBackground("bgtest", data, Client.JobPriority.HIGH); while(!c.checkIsDone(jobhandle)) { Console.WriteLine("Still not done!"); Thread.Sleep(1500); } w.stopWorkLoop(); }
public void testWordCountIPv6() { Worker w = new Worker("::1"); w.registerFunction("wc", wctest); w.workLoop(); Client c = new Client("::1"); byte[] data = new ASCIIEncoding().GetBytes("zzz\nyyy\napple\nbaz\nfoo\nnarf\nquiddle\n"); byte[] result = c.submitJob("wc", data); Assert.IsNotNull(result); int resultasint = BitConverter.ToInt32(result, 0); Assert.AreEqual(resultasint, 7); w.stopWorkLoop(); }
public void testTimeout() { Worker w = new Worker("localhost"); w.registerFunction("infinite", infinite); w.workLoop(); DateTime start = DateTime.Now; Console.WriteLine("Started: {0}", start); Client c = new Client("localhost"); byte[] data = new ASCIIEncoding().GetBytes("zzz\nyyy\napple\nbaz\nfoo\nnarf\nquiddle\n"); c.submitJob("infinite", data); DateTime stop = DateTime.Now; Console.WriteLine("Connection died at {1}", stop); w.stopWorkLoop(); }