Class SchedulerExtensions
- Namespace
- ReactiveUI.Testing
- Assembly
- ReactiveUI.Testing.dll
Extension methods for the test based schedulers.
- Inheritance
-
Scheduler
Extensions
Methods
AdvanceByMs(TestScheduler, double)
AdvanceByMs moves the TestScheduler along by the specified time in milliseconds.
Parameters
scheduler
TestScheduler The scheduler to advance.
milliseconds
doubleThe relative time to advance the TestScheduler by, in milliseconds.
AdvanceToMs(TestScheduler, double)
AdvanceToMs moves the TestScheduler to the specified time in milliseconds.
Parameters
scheduler
TestScheduler The scheduler to advance.
milliseconds
doubleThe time offset to set the TestScheduler to, in milliseconds. Note that this is not additive or incremental, it sets the time.
FromTimeSpan(TestScheduler, TimeSpan)
Converts a timespan to a virtual time for testing.
Parameters
scheduler
TestScheduler The scheduler.
span
TimeSpan Timespan to convert.
Returns
- long
Timespan for virtual scheduler to use.
OnCompletedAt<T>(TestScheduler, double)
OnCompletedAt is a method to help create simulated input Observables in conjunction with CreateHotObservable or CreateColdObservable.
public static Recorded<Notification<T>> OnCompletedAt<T>(this TestScheduler scheduler, double milliseconds)
Parameters
scheduler
TestScheduler The scheduler to fire from.
milliseconds
doubleThe time offset to fire the notification on the recorded notification.
Returns
- Recorded<Notification<T>>
A recorded notification that can be provided to TestScheduler.CreateHotObservable.
Type Parameters
T
The type.
OnErrorAt<T>(TestScheduler, double, Exception)
OnErrorAt is a method to help create simulated input Observables in conjunction with CreateHotObservable or CreateColdObservable.
public static Recorded<Notification<T>> OnErrorAt<T>(this TestScheduler scheduler, double milliseconds, Exception ex)
Parameters
scheduler
TestScheduler The scheduler to fire from.
milliseconds
doubleThe time offset to fire the notification on the recorded notification.
ex
ExceptionThe exception to terminate the Observable with.
Returns
- Recorded<Notification<T>>
A recorded notification that can be provided to TestScheduler.CreateHotObservable.
Type Parameters
T
The type.
OnNextAt<T>(TestScheduler, double, T)
OnNextAt is a method to help create simulated input Observables in conjunction with CreateHotObservable or CreateColdObservable.
public static Recorded<Notification<T>> OnNextAt<T>(this TestScheduler scheduler, double milliseconds, T value)
Parameters
scheduler
TestScheduler The scheduler to fire from.
milliseconds
doubleThe time offset to fire the notification on the recorded notification.
value
TThe value to produce.
Returns
- Recorded<Notification<T>>
A recorded notification that can be provided to TestScheduler.CreateHotObservable.
Type Parameters
T
The type.
WithAsync<T>(T, Func<T, Task>)
With is an extension method that uses the given scheduler as the default Deferred and Taskpool schedulers for the given Action.
Parameters
Returns
Type Parameters
T
The type.
WithAsync<T, TRet>(T, Func<T, Task<TRet>>)
With is an extension method that uses the given scheduler as the default Deferred and Taskpool schedulers for the given Func. Use this to initialize objects that store the default scheduler (most RxXaml objects).
public static Task<TRet> WithAsync<T, TRet>(this T scheduler, Func<T, Task<TRet>> block) where T : IScheduler
Parameters
Returns
- Task<TRet>
The return value of the function.
Type Parameters
T
The type.
TRet
The return type.
WithScheduler(IScheduler)
WithScheduler overrides the default Deferred and Taskpool schedulers with the given scheduler until the return value is disposed. This is useful in a unit test runner to force RxXaml objects to schedule via a TestScheduler object.
Parameters
scheduler
ISchedulerThe scheduler to use.
Returns
- IDisposable
An object that when disposed, restores the previous default schedulers.
With<T>(T, Action<T>)
With is an extension method that uses the given scheduler as the default Deferred and Taskpool schedulers for the given Action.
Parameters
scheduler
TThe scheduler to use.
block
Action<T>The action to execute.
Type Parameters
T
The type.
With<T, TRet>(T, Func<T, TRet>)
With is an extension method that uses the given scheduler as the default Deferred and Taskpool schedulers for the given Func. Use this to initialize objects that store the default scheduler (most RxXaml objects).
Parameters
scheduler
TThe scheduler to use.
block
Func<T, TRet>The function to execute.
Returns
- TRet
The return value of the function.
Type Parameters
T
The scheduler type.
TRet
The return type.