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>
impl<T: Sized + Unpin + 'static, Error: 'static> ActorExpect<T, Error>
Sourcepub fn expect_send<I, O>(
incoming: I,
outgoing: O,
default_outgoing: Option<O>,
) -> Self
pub fn expect_send<I, O>( incoming: I, outgoing: O, default_outgoing: Option<O>, ) -> Self
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 thanincoming
. IfNone
is set, actor mailbox is closed on unsupported message.
Sourcepub fn placeholder<O: 'static + Clone + PartialEq>() -> Self
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.
Sourcepub fn total_calls(&self) -> usize
pub fn total_calls(&self) -> usize
Returns a total number of calls that the mocker received.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more