FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ferroui_reactive_testing

    module · ferroui-reactive-testing · v0.5.0

    module ferroui_reactive_testing
    

    ferroui-reactive-testing

    A port of Microsoft.Reactive.Testing (https://github.com/dotnet/reactive) for ferroui-reactive: the virtual-time TestScheduler, recorded notifications (Recorded) and subscriptions (Subscription), hot and cold test observables, the observer that records what it receives, the factories of ReactiveTest and the assertions of ReactiveAssert.

    A test in the style of upstream:

    use ferroui_reactive::ObservableExt;
    use ferroui_reactive_testing::{assert_messages, assert_subscriptions, ReactiveTest as RT, TestScheduler};
    
    let scheduler = TestScheduler::new();
    let xs = scheduler.create_hot_observable(vec![RT::on_next(150, 1), RT::on_next(210, 2), RT::on_completed(250)]);
    let source = xs.as_observable();
    let res = scheduler.start(move || source.clone());
    assert_messages!(res.messages(), RT::on_next(210, 2), RT::on_completed::<i32>(250));
    // A hot observable subscribed directly keeps the subscription until it is disposed.
    assert_subscriptions!(xs.subscriptions(), RT::subscribe(200, 1000));
    

    View source

    Contents

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.