File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -533,5 +533,41 @@ public void CombinedCommandsShouldReflectParentCanExecute()
533533 Assert . Equal ( 3 , canExecuteOutput . Count ) ;
534534 Assert . Equal ( true , canExecuteOutput [ 2 ] ) ;
535535 }
536+
537+ [ Fact ]
538+ public void TaskExceptionsShouldBeMarshaledToThrownExceptions ( )
539+ {
540+ ( new TestScheduler ( ) ) . With ( sched => {
541+ var fixture = new ReactiveCommand ( ) ;
542+
543+ int result = 0 ;
544+ fixture . RegisterAsyncTask ( async _ => {
545+ await Observable . Timer ( TimeSpan . FromMilliseconds ( 50 ) , RxApp . TaskpoolScheduler ) ;
546+ throw new Exception ( "Die" ) ;
547+ return 5 ;
548+ } ) . Subscribe ( x => result = x ) ;
549+
550+ var error = default ( Exception ) ;
551+ fixture . ThrownExceptions . Subscribe ( ex => error = ex ) ;
552+
553+ fixture . Execute ( null ) ;
554+
555+ sched . AdvanceByMs ( 20 ) ;
556+ Assert . Null ( error ) ;
557+ Assert . Equal ( 0 , result ) ;
558+
559+ // NB: We have to Thread.Sleep here to compensate for not being
560+ // able to control the concurrency of Task
561+ sched . AdvanceByMs ( 100 ) ;
562+ Thread . Sleep ( 100 ) ;
563+
564+ // NB: Advance it one more so that the scheduled ThrownExceptions
565+ // end up being dispatched
566+ sched . AdvanceByMs ( 10 ) ;
567+
568+ Assert . NotNull ( error ) ;
569+ Assert . Equal ( 0 , result ) ;
570+ } ) ;
571+ }
536572 }
537573}
Original file line number Diff line number Diff line change @@ -451,4 +451,4 @@ public class ViewContractAttribute : Attribute
451451 }
452452}
453453
454- // vim: tw=120 ts=4 sw=4 et :
454+ // vim: tw=120 ts=4 sw=4 et :
Original file line number Diff line number Diff line change 6666 <Compile Include =" ..\CommonAssemblyInfo.cs" >
6767 <Link >Properties\CommonAssemblyInfo.cs</Link >
6868 </Compile >
69+ <Compile Include =" Activation.cs" />
6970 <Compile Include =" ReactiveBinding.cs" />
7071 <Compile Include =" AutoPersistHelper.cs" />
7172 <Compile Include =" BindingTypeConverters.cs" />
You can’t perform that action at this time.
0 commit comments