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.
SchedulerExtensions: runs code with a scheduler, typically aTestScheduler, as both schedulers ofRxSchedulers(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 asMessageBus::current(MessageBusExtensions).IBuilderandIBuilderExtensions: the builders of test data (IBuilder,IBuilderExtensions).RxTestandAppBuilderTestBase: 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.
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). - Test
Sequencer - Two participants of a test that wait for each other phase by phase: each calls
advance_phase_asyncat the end of its part of a phase, and the phase completes when both have (TestSequencer, aBarrierof two participants).
Traits§
- AppBuilder
Test Base - 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). - IBuilder
Extensions - The fluent setters of a builder of test data (
IBuilderExtensions): each sets or fills a field of the builder and returns the builder. - Message
BusExtensions - Runs code with a message bus as
MessageBus::current(MessageBusExtensions). - Scheduler
Extensions - Runs code with a scheduler as both schedulers of
RxSchedulers, the main thread scheduler and the task pool scheduler (SchedulerExtensions). - Test
Scheduler Extensions - The virtual time of a
TestSchedulerin milliseconds, and recorded notifications at a time in milliseconds (TestSchedulerExtensions, from ReactiveUI.Testing.Reactive).