public override object Clone() { AsyncProxyableEcho clone = new AsyncProxyableEcho(); clone.CopyProperties(this); clone.CopyEventHandlers(this); return(clone); }
private static AsyncProxyableEcho GetTestAsyncProxyable() { ServiceProxyTestHelpers.StartSecureChannelTestServerGetClient(out BamServer server, out SecureServiceProxyClient <AsyncProxyableEcho> sspc); ConsoleLogger logger = GetTestConsoleLogger(); ProxyFactory serviceFactory = new ProxyFactory(".\\workspace_".RandomLetters(4), logger); AsyncCallbackService callbackService = new AsyncCallbackService(new AsyncCallback.Data.Dao.Repository.AsyncCallbackRepository(), new AppConf()); AsyncProxyableEcho testObj = serviceFactory.GetProxy <AsyncProxyableEcho>(server.DefaultHostPrefix.HostName, server.DefaultHostPrefix.Port, logger); // the "server" testObj.CallbackService = callbackService; return(testObj); }
public void ShouldBeAbleToUseGenericInvokeAsync() { AsyncProxyableEcho testObj = GetTestAsyncProxyable(); AutoResetEvent blocker = new AutoResetEvent(false); string value = "this is a value: ".RandomString(8); Task <string> task = testObj.InvokeAsync <string>("Send", value); task.Wait(1000 * 60 * 3); StopServers(); Expect.AreEqual(value, task.Result); }
public void ShouldUseCacheInvokeAsync() { AsyncProxyableEcho testObj = GetTestAsyncProxyable(); AutoResetEvent blocker = new AutoResetEvent(false); string value = "this is a value"; Task <string> task = testObj.InvokeAsync <string>("Send", value); task.Wait(1000 * 60 * 3); StopServers(); Expect.AreEqual(value, task.Result); // TODO: add better assertions that validate that the remote call wasn't made and the result was retrieved from the local repo }
public void ShouldBeAbleToUseInvokeAsync() { AsyncProxyableEcho testObj = GetTestAsyncProxyable(); AutoResetEvent blocker = new AutoResetEvent(false); string value = "this is a value: ".RandomString(8); bool? ran = false; testObj.InvokeAsync(r => { ran = true; Expect.AreEqual(value, r.Result); blocker.Set(); }, "Send", value); blocker.WaitOne(1000 * 60 * 3); StopServers(); Expect.IsTrue(ran.Value); }