@@ -40,6 +40,7 @@ public async Task ProgressiveCallsCallerProgress()
4040 Assert . That ( result , Is . EqualTo ( 10 ) ) ;
4141 }
4242
43+
4344 [ Test ]
4445 public async Task ProgressiveCallsCallerProgressObservable ( )
4546 {
@@ -116,6 +117,31 @@ public async Task ProgressiveCallsCalleeProxyProgress()
116117 Assert . That ( result , Is . EqualTo ( "10" ) ) ;
117118 }
118119
120+ [ Test ]
121+ public async Task ProgressiveCallsCalleeProxyProgressValueTuples ( )
122+ {
123+ WampPlayground playground = new WampPlayground ( ) ;
124+
125+ CallerCallee dualChannel = await playground . GetCallerCalleeDualChannel ( ) ;
126+ IWampChannel calleeChannel = dualChannel . CalleeChannel ;
127+ IWampChannel callerChannel = dualChannel . CallerChannel ;
128+
129+ MyValueTupleOperation myOperation = new MyValueTupleOperation ( ) ;
130+
131+ await calleeChannel . RealmProxy . RpcCatalog . Register ( myOperation , new RegisterOptions ( ) ) ;
132+ ILongOpService proxy = callerChannel . RealmProxy . Services . GetCalleeProxy < ILongOpService > ( ) ;
133+
134+ List < ( int a , int b ) > results = new List < ( int a , int b ) > ( ) ;
135+ MyProgress < ( int a , int b ) > progress = new MyProgress < ( int a , int b ) > ( i => results . Add ( i ) ) ;
136+
137+ var result = await proxy . LongOpValueTuple ( 10 , progress ) ;
138+
139+ CollectionAssert . AreEquivalent ( Enumerable . Range ( 0 , 10 ) . Select ( x => ( a : x , b : x ) ) , results ) ;
140+
141+ Assert . That ( result , Is . EqualTo ( ( 10 , "10" ) ) ) ;
142+ }
143+
144+
119145 [ Test ]
120146 public async Task ProgressiveCallsCalleeProxyObservable ( )
121147 {
@@ -205,11 +231,72 @@ public IWampCancellableInvocation Invoke<TMessage>(IWampRawRpcOperationRouterCal
205231 }
206232 }
207233
234+ public class MyValueTupleOperation : IWampRpcOperation
235+ {
236+ public const string ProcedureUri = "com.myapp.longopvaluetuple" ;
237+
238+ public string Procedure => ProcedureUri ;
239+
240+ public IWampCancellableInvocation Invoke < TMessage > ( IWampRawRpcOperationRouterCallback caller , IWampFormatter < TMessage > formatter , InvocationDetails details )
241+ {
242+ return null ;
243+ }
244+
245+ public IWampCancellableInvocation Invoke < TMessage > ( IWampRawRpcOperationRouterCallback caller , IWampFormatter < TMessage > formatter ,
246+ InvocationDetails details ,
247+ TMessage [ ] arguments )
248+ {
249+ TMessage number = arguments [ 0 ] ;
250+ int n = formatter . Deserialize < int > ( number ) ;
251+
252+ for ( int i = 0 ; i < n ; i ++ )
253+ {
254+ caller . Result ( WampObjectFormatter . Value ,
255+ new YieldOptions { Progress = true } ,
256+ new object [ ] { } ,
257+ new Dictionary < string , object >
258+ {
259+ { "a" , i } ,
260+ { "b" , i }
261+ } ) ;
262+ }
263+
264+ if ( EndWithError )
265+ {
266+ caller . Error ( WampObjectFormatter . Value ,
267+ new Dictionary < string , string > ( ) ,
268+ "longop.error" ,
269+ new object [ ] { "Something bad happened" } ) ;
270+ }
271+ else
272+ {
273+ caller . Result ( WampObjectFormatter . Value ,
274+ new YieldOptions ( ) ,
275+ new object [ ] { n , n . ToString ( ) } ) ;
276+ }
277+
278+ return null ;
279+ }
280+
281+ public bool EndWithError { get ; set ; }
282+
283+ public IWampCancellableInvocation Invoke < TMessage > ( IWampRawRpcOperationRouterCallback caller , IWampFormatter < TMessage > formatter , InvocationDetails details ,
284+ TMessage [ ] arguments , IDictionary < string , TMessage > argumentsKeywords )
285+ {
286+ return null ;
287+ }
288+ }
289+
208290 public interface ILongOpService
209291 {
210292 [ WampProcedure ( MyOperation . ProcedureUri ) ]
211293 [ WampProgressiveResultProcedure ]
212294 Task < string > LongOp ( int n , IProgress < int > progress ) ;
295+
296+ [ WampProcedure ( MyValueTupleOperation . ProcedureUri ) ]
297+ [ WampProgressiveResultProcedure ]
298+ Task < ( int , string ) > LongOpValueTuple ( int n , IProgress < ( int a , int b ) > progress ) ;
299+
213300 }
214301
215302 public class LongOpService : ILongOpService
@@ -224,6 +311,17 @@ public async Task<string> LongOp(int n, IProgress<int> progress)
224311
225312 return n . ToString ( ) ;
226313 }
314+
315+ public async Task < ( int , string ) > LongOpValueTuple ( int n , IProgress < ( int a , int b ) > progress )
316+ {
317+ for ( int i = 0 ; i < n ; i ++ )
318+ {
319+ progress . Report ( ( i , i ) ) ;
320+ await Task . Delay ( 100 ) ;
321+ }
322+
323+ return ( n , n . ToString ( ) ) ;
324+ }
227325 }
228326
229327 public interface ILongOpObservableService
0 commit comments