1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! ferroui-reactiveui-testing
//!
//! A port of ReactiveUI.Testing and ReactiveUI.Testing.Reactive
//! (<https://github.com/reactiveui/ReactiveUI>) for `ferroui-reactiveui`: the helpers of the tests
//! of view models and of the code that runs on ReactiveUI's schedulers.
//!
//! - [`SchedulerExtensions`]: runs code with a scheduler, typically a
//! [`TestScheduler`](ferroui_reactive_testing::TestScheduler), as both schedulers of
//! [`RxSchedulers`](ferroui_reactiveui::RxSchedulers) (`SchedulerExtensions`).
//! - [`TestSchedulerExtensions`]: the virtual time of the test scheduler in milliseconds, and
//! recorded notifications at a time in milliseconds (`TestSchedulerExtensions`, from
//! ReactiveUI.Testing.Reactive).
//! - [`MessageBusExtensions`]: runs code with a message bus as
//! [`MessageBus::current`](ferroui_reactiveui::MessageBus::current) (`MessageBusExtensions`).
//! - [`IBuilder`] and [`IBuilderExtensions`]: the builders of test data (`IBuilder`,
//! `IBuilderExtensions`).
//! - [`RxTest`] and [`AppBuilderTestBase`]: run a test of the application builder of Splat from a
//! clean builder state, one at a time and within a time limit (`RxTest`, `AppBuilderTestBase`).
//! - [`TestSequencer`]: two participants of a test that wait for each other phase by phase
//! (`TestSequencer`).
//!
//! A test that runs a view model on a test scheduler:
//!
//! ```
//! use ferroui_reactive_testing::TestScheduler;
//! use ferroui_reactiveui::RxSchedulers;
//! use ferroui_reactiveui_testing::{SchedulerExtensions, TestSchedulerExtensions};
//! use std::rc::Rc;
//!
//! let scheduler = TestScheduler::new();
//! scheduler.with(|scheduler| {
//! assert!(Rc::ptr_eq(&RxSchedulers::main_thread_scheduler(), &scheduler.scheduler()));
//! scheduler.advance_by_ms(250.0);
//! assert_eq!(scheduler.clock(), TestScheduler::from_time_span(std::time::Duration::from_millis(250)));
//! });
//! ```
//!
//! Everything is single-threaded, as `ferroui-reactiveui` is (`docs/porting/reactive.md`, section
//! 5.1): the state these helpers set (the schedulers, the message bus, the state of the
//! application builder) is the state of the current thread.
pub use AppBuilderTestBase;
pub use IBuilder;
pub use IBuilderExtensions;
pub use MessageBusExtensions;
pub use RxTest;
pub use SchedulerExtensions;
pub use TestSchedulerExtensions;
pub use TestSequencer;