actix_actor_expect

Struct ActorExpect

Source
pub struct ActorExpect<T: Sized + Unpin + 'static, Error: 'static> {
    pub addr: Addr<Mocker<T>>,
    /* private fields */
}
Expand description

Utility for unit testing actix actors. Helper for reducing the boilerplate when unit testing actix actors. Configures a mocker actor to expect a particular incoming command I and to respond with provided outgoing response O.

Fields§

§addr: Addr<Mocker<T>>

Implementations§

Source§

impl<T: Sized + Unpin + 'static, Error: 'static> ActorExpect<T, Error>

Source

pub fn expect_send<I, O>( incoming: I, outgoing: O, default_outgoing: Option<O>, ) -> Self
where I: 'static + Clone + PartialEq + Message + Send, I::Result: Send, O: 'static + Clone + PartialEq,

Creates a mocker that accepts incoming and returns outgoing message. If other messages are received, default_outgoing message is returned.

§Arguments
  • incoming - incoming message for actor.
  • outgoing - response message for actor when incoming received.
  • default_outgoing - default response message for anything other than incoming. If None is set, actor mailbox is closed on unsupported message.
Source

pub fn placeholder<O: 'static + Clone + PartialEq>() -> Self

Creates an actor that is a placeholder:

  • it doesn’t accept sent messages.
  • if message is received, inbox closes right away.
Source

pub fn total_calls(&self) -> usize

Returns a total number of calls that the mocker received.

Source

pub fn calls_of_variant<MSG: Any + 'static + PartialEq>( &self, msg: MSG, ) -> usize

Returns a total number of calls that the mocker received for msg type or variant.

§Arguments
  • msg - message for actor

Auto Trait Implementations§

§

impl<T, Error> Freeze for ActorExpect<T, Error>

§

impl<T, Error> !RefUnwindSafe for ActorExpect<T, Error>

§

impl<T, Error> !Send for ActorExpect<T, Error>

§

impl<T, Error> !Sync for ActorExpect<T, Error>

§

impl<T, Error> Unpin for ActorExpect<T, Error>
where Error: Unpin,

§

impl<T, Error> !UnwindSafe for ActorExpect<T, Error>

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>,

Source§

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>,

Source§

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.