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,

source

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.

source

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.

source

pub fn view(&self, model: &App::Model) -> App::ViewModel

Run the app’s view function with a model state

Trait Implementations§

source§

impl<App, Ef> AsRef<<App as App>::Capabilities> for AppTester<App, Ef>where App: App,

source§

fn as_ref(&self) -> &App::Capabilities

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<App, Ef> Default for AppTester<App, Ef>where App: App, App::Capabilities: WithContext<App, Ef>, App::Event: Send, Ef: Send + 'static,

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<App, Ef> RefUnwindSafe for AppTester<App, Ef>where App: RefUnwindSafe, <App as App>::Capabilities: RefUnwindSafe,

§

impl<App, Ef> !Send for AppTester<App, Ef>

§

impl<App, Ef> !Sync for AppTester<App, Ef>

§

impl<App, Ef> Unpin for AppTester<App, Ef>where App: Unpin, <App as App>::Capabilities: Unpin,

§

impl<App, Ef> UnwindSafe for AppTester<App, Ef>where App: UnwindSafe, <App as App>::Capabilities: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.