pub struct AppTester<App, Ef>where
App: App,{ /* private fields */ }
Expand description
AppTester is a simplified execution environment for Crux apps for use in tests.
Create an instance of AppTester
with your App
and an Effect
type
using AppTester::default
.
for example:
let app = AppTester::<ExampleApp, ExampleEffect>::default();
Implementations§
source§impl<App, Ef> AppTester<App, Ef>where
App: App,
impl<App, Ef> AppTester<App, Ef>where
App: App,
sourcepub fn new(app: App) -> Self
pub fn new(app: App) -> Self
Create an AppTester
instance for an existing app instance. This can be used if your App
has a constructor other than Default
, for example when used as a child app and expecting
configuration from the parent
sourcepub fn update(
&self,
event: App::Event,
model: &mut App::Model,
) -> Update<Ef, App::Event>
pub fn update( &self, event: App::Event, model: &mut App::Model, ) -> Update<Ef, App::Event>
Run the app’s update
function with an event and a model state
You can use the resulting Update
to inspect the effects which were requested
and potential further events dispatched by capabilities.
sourcepub fn resolve<Op: Operation>(
&self,
request: &mut Request<Op>,
value: Op::Output,
) -> Result<Update<Ef, App::Event>>
pub fn resolve<Op: Operation>( &self, request: &mut Request<Op>, value: Op::Output, ) -> Result<Update<Ef, App::Event>>
Resolve an effect request
from previous update with an operation output.
This potentially runs the app’s update
function if the effect is completed, and
produce another Update
.
sourcepub fn resolve_to_event_then_update<Op: Operation>(
&self,
request: &mut Request<Op>,
value: Op::Output,
model: &mut App::Model,
) -> Update<Ef, App::Event>
pub fn resolve_to_event_then_update<Op: Operation>( &self, request: &mut Request<Op>, value: Op::Output, model: &mut App::Model, ) -> Update<Ef, App::Event>
Resolve an effect request
from previous update, then run the resulting event
This helper is useful for the common case where one expects the effect to resolve to exactly one event, which should then be run by the app.