pub struct TestHandler<H>where
    H: GameHandler,{ /* private fields */ }
Expand description

A wrapped handler for testing This handler includes the general event handling, which is necessary for integration test.

Implementations§

source§

impl<H: GameHandler> TestHandler<H>

source

pub fn init_state( context: &mut GameContext, game_account: &GameAccount ) -> Result<Self>

source

pub fn handle_event( &mut self, context: &mut GameContext, event: &Event ) -> Result<()>

source

pub fn handle_dispatch_event(&mut self, context: &mut GameContext) -> Result<()>

Find the event which is going to be disptached in the context, then process it. In real cases, the disptached event will be handled by an event loop. We use this function to simulate such cases, since we don’t have an event loop in tests.

source

pub fn handle_until_no_events( &mut self, context: &mut GameContext, event: &Event, clients: Vec<&mut TestClient> ) -> Result<()>

This fn keeps handling events of the following two types, until there is none:

  1. Event dispatched from within the (updated) context: context.dispatch
  2. Event dispatched by clients after they see the updated context
source

pub fn get_state(&self) -> &H

source

pub fn get_mut_state(&mut self) -> &mut H

Auto Trait Implementations§

§

impl<H> RefUnwindSafe for TestHandler<H>where H: RefUnwindSafe,

§

impl<H> Send for TestHandler<H>where H: Send,

§

impl<H> Sync for TestHandler<H>where H: Sync,

§

impl<H> Unpin for TestHandler<H>where H: Unpin,

§

impl<H> UnwindSafe for TestHandler<H>where H: 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> Same for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V