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