public async Task ProgressiveCancellationTokenCancelCallsInterrupt() { WampPlayground playground = new WampPlayground(); CallerCallee dualChannel = await playground.GetCallerCalleeDualChannel(); IWampChannel calleeChannel = dualChannel.CalleeChannel; IWampChannel callerChannel = dualChannel.CallerChannel; MyCancellableOperation myOperation = new MyCancellableOperation("com.myapp.longop"); await calleeChannel.RealmProxy.RpcCatalog.Register(myOperation, new RegisterOptions()); ICancellableLongOpService proxy = callerChannel.RealmProxy.Services.GetCalleeProxyPortable <ICancellableLongOpService>(); CancellationTokenSource tokenSource = new CancellationTokenSource(); MyProgress <int> progress = new MyProgress <int>(x => { }); Task <int> result = proxy.LongOp(10, progress, tokenSource.Token); Assert.That(myOperation.CancellableInvocation.InterruptCalled, Is.False); tokenSource.Cancel(); Assert.That(myOperation.CancellableInvocation.InterruptCalled, Is.True); }
public async Task ProgressiveCallsCalleeProxyProgress() { WampPlayground playground = new WampPlayground(); CallerCallee dualChannel = await playground.GetCallerCalleeDualChannel(); IWampChannel calleeChannel = dualChannel.CalleeChannel; IWampChannel callerChannel = dualChannel.CallerChannel; MyOperation myOperation = new MyOperation(); await calleeChannel.RealmProxy.RpcCatalog.Register(myOperation, new RegisterOptions()); ILongOpService proxy = callerChannel.RealmProxy.Services.GetCalleeProxy <ILongOpService>(); List <int> results = new List <int>(); MyProgress <int> progress = new MyProgress <int>(i => results.Add(i)); Task <int> result = proxy.LongOp(10, progress); result.Wait(); CollectionAssert.AreEquivalent(Enumerable.Range(0, 10), results); Assert.That(result.Result, Is.EqualTo(10)); }