# TestScheduler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive-testing/struct-testscheduler/

**struct** · [`ferroui-reactive-testing`](/docs/0.5.0/api/ferroui-reactive-testing/) · v0.5.0

```rust
struct TestScheduler
```

A virtual-time scheduler for tests, whose clock counts ticks (`TestScheduler`). It dereferences to
the virtual-time scheduler (`clock`, `start`, `advance_to`, `advance_by`, `sleep`,
`schedule_absolute`, ...).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L85)

## Members

- [`new`](#function-new)
- [`scheduler`](#function-scheduler)
- [`schedule_absolute_action`](#function-schedule_absolute_action)
- [`start_with`](#function-start_with)
- [`start_disposed`](#function-start_disposed)
- [`start`](#function-start)
- [`run`](#function-run)
- [`create_hot_observable`](#function-create_hot_observable)
- [`create_cold_observable`](#function-create_cold_observable)
- [`create_observer`](#function-create_observer)

<a id="function-new"></a>

### new

```rust
fn new() -> Self
```

A scheduler with its clock at zero.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L105)

<a id="function-scheduler"></a>

### scheduler

```rust
fn scheduler(self: &Self) -> Rc<dyn IScheduler>
```

The scheduler as the handle operators take.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L110)

<a id="function-schedule_absolute_action"></a>

### schedule_absolute_action

```rust
fn schedule_absolute_action(self: &Self, due_time: i64, action: impl FnOnce() -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action at an absolute virtual time.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L115)

<a id="function-start_with"></a>

### start_with

```rust
fn start_with<T: Clone + 'static>(self: &Self, create: impl FnOnce() -> Rc<dyn IObservable<T>> + 'static, created: i64, subscribed: i64, disposed: i64) -> Rc<MockObserver<T>>
```

Creates the sequence at `created`, subscribes an observer at `subscribed` and disposes the
subscription at `disposed`, runs the scheduler, and returns the observer with what it
recorded (`Start(Func<IObservable<T>>, long, long, long)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L128)

<a id="function-start_disposed"></a>

### start_disposed

```rust
fn start_disposed<T: Clone + 'static>(self: &Self, create: impl FnOnce() -> Rc<dyn IObservable<T>> + 'static, disposed: i64) -> Rc<MockObserver<T>>
```

`start_with` at the default times, created at 100, subscribed at 200 and
disposed at `disposed` (`Start(Func<IObservable<T>>, long)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L166)

<a id="function-start"></a>

### start

```rust
fn start<T: Clone + 'static>(self: &Self, create: impl FnOnce() -> Rc<dyn IObservable<T>> + 'static) -> Rc<MockObserver<T>>
```

`start_with` at the default times: created at 100, subscribed at 200,
disposed at 1000 (`Start(Func<IObservable<T>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L172)

<a id="function-run"></a>

### run

```rust
fn run(self: &Self)
```

Runs the queued work (`VirtualTimeScheduler.Start()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L177)

<a id="function-create_hot_observable"></a>

### create_hot_observable

```rust
fn create_hot_observable<T: Clone + 'static>(self: &Self, messages: Vec<Recorded<Notification<T>>>) -> Rc<HotObservable<T>>
```

A sequence that notifies its messages at their absolute times to the observers subscribed
then (`CreateHotObservable`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L183)

<a id="function-create_cold_observable"></a>

### create_cold_observable

```rust
fn create_cold_observable<T: Clone + 'static>(self: &Self, messages: Vec<Recorded<Notification<T>>>) -> Rc<ColdObservable<T>>
```

A sequence that notifies its messages at their times relative to each subscription
(`CreateColdObservable`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L189)

<a id="function-create_observer"></a>

### create_observer

```rust
fn create_observer<T: 'static>(self: &Self) -> Rc<MockObserver<T>>
```

An observer that records what it receives with the time (`CreateObserver`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive.Testing/lib.rs#L194)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- `Clone`
- `Default`
- `Deref`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
