Skip to main content

Crate ferroui_reactiveui_testing

Crate ferroui_reactiveui_testing 

Source
Expand description

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.

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.

Structs§

RxTest
Runs a test of the application builder of Splat from a clean builder state, one test at a time and within a time limit (RxTest).
TestSequencer
Two participants of a test that wait for each other phase by phase: each calls advance_phase_async at the end of its part of a phase, and the phase completes when both have (TestSequencer, a Barrier of two participants).

Traits§

AppBuilderTestBase
The base of the fixtures of tests of the application builder, which gives them RxTest::app_builder_test_async (AppBuilderTestBase).
IBuilder
The marker of a builder of test data, which gets the methods of IBuilderExtensions (IBuilder).
IBuilderExtensions
The fluent setters of a builder of test data (IBuilderExtensions): each sets or fills a field of the builder and returns the builder.
MessageBusExtensions
Runs code with a message bus as MessageBus::current (MessageBusExtensions).
SchedulerExtensions
Runs code with a scheduler as both schedulers of RxSchedulers, the main thread scheduler and the task pool scheduler (SchedulerExtensions).
TestSchedulerExtensions
The virtual time of a TestScheduler in milliseconds, and recorded notifications at a time in milliseconds (TestSchedulerExtensions, from ReactiveUI.Testing.Reactive).