Table of Contents

Class SchedulerExtensions

Namespace
ReactiveUI.Testing
Assembly
ReactiveUI.Testing.dll

Extension methods for the test based schedulers.

public static class SchedulerExtensions
Inheritance
SchedulerExtensions

Methods

AdvanceByMs(TestScheduler, double)

AdvanceByMs moves the TestScheduler along by the specified time in milliseconds.

public static void AdvanceByMs(this TestScheduler scheduler, double milliseconds)

Parameters

scheduler TestScheduler

The scheduler to advance.

milliseconds double

The relative time to advance the TestScheduler by, in milliseconds.

AdvanceToMs(TestScheduler, double)

AdvanceToMs moves the TestScheduler to the specified time in milliseconds.

public static void AdvanceToMs(this TestScheduler scheduler, double milliseconds)

Parameters

scheduler TestScheduler

The scheduler to advance.

milliseconds double

The 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.

public static long FromTimeSpan(this TestScheduler scheduler, TimeSpan span)

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 double

The 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 double

The time offset to fire the notification on the recorded notification.

ex Exception

The 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 double

The time offset to fire the notification on the recorded notification.

value T

The 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.

public static Task WithAsync<T>(this T scheduler, Func<T, Task> block) where T : IScheduler

Parameters

scheduler T

The scheduler to use.

block Func<T, Task>

The action to execute.

Returns

Task

A Task representing the asynchronous operation.

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

scheduler T

The scheduler to use.

block Func<T, Task<TRet>>

The function to execute.

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.

public static IDisposable WithScheduler(IScheduler scheduler)

Parameters

scheduler IScheduler

The 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.

public static void With<T>(this T scheduler, Action<T> block) where T : IScheduler

Parameters

scheduler T

The 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).

public static TRet With<T, TRet>(this T scheduler, Func<T, TRet> block) where T : IScheduler

Parameters

scheduler T

The 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.