Struct crux_core::testing::AppTester

source ·
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 new(app: App) -> Self
where Ef: Send + 'static, App::Capabilities: WithContext<App::Event, Ef>,

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

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::Event, Ef>, Ef: Send + 'static,

source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

impl<App, Ef> RefUnwindSafe for AppTester<App, Ef>

§

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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.