Expectations

Struct Expectations 

Source
pub struct Expectations { /* private fields */ }

Implementations§

Source§

impl Expectations

Source

pub fn new() -> Expectations

Create a new Expectations instance. Call this when your mock object is created.

Source

pub fn expect<I, O>(&mut self, name: &'static str) -> Method<'_, I, O>
where I: 'static, O: 'static,

Returns a Method struct which you can use to add expectations for the method with the given name.

Source

pub fn then(&mut self) -> &mut Expectations

Begin a new Era. Expectations in one Era must be met before expectations in future eras will be evaluated.

Note that Eras are evaluated eagerly. This means that Eras may advance more quickly than you’d intuitively expect in certain situations. For example, called_any() is marked as complete after the first call is received. This menas that, for the purposes of telling if an Era should be advanced or not, called_any() and called_once() are the same.

Source

pub fn was_called<I, O>(&self, name: &'static str, params: I)
where I: 'static, O: 'static,

When a tracked method is called on the mock object, call this with the method’s name in order to tell the Expectations that the method was called.

Unlike was_called_returning, this method does not return a value.

Source

pub fn was_called_returning<I, O>(&self, name: &'static str, params: I) -> O
where I: 'static, O: 'static,

Same as the was_called method, but also returns the result.

Trait Implementations§

Source§

impl Drop for Expectations

Source§

fn drop(&mut self)

All expectations will be verified when the mock object is dropped, panicking if any of them are unmet.

In the case where the Expectations object is being dropped because the thread is already panicking, the Expectations object is not verified.

Auto Trait Implementations§

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.