Struct mry::MockLocator

source ·
pub struct MockLocator<I, O, B> { /* private fields */ }
Expand description

Mock locator returned by mock_* methods

Implementations§

source§

impl<I, O, B> MockLocator<I, O, B>
where I: 'static, O: 'static, B: Into<Behavior<I, O>>,

source

pub fn returns_with<T: Into<B>>(self, behavior: T) -> Self

Returns value with using a closure. Arguments of a method call are passed to the given closure.

source

pub fn returns_once(self, ret: O) -> Self

Returns value once. After that, it panics.

source§

impl<I, O, B> MockLocator<I, O, B>
where I: 'static, O: 'static,

source

pub fn calls_real_impl(self) -> Self

This make the mock calls real impl. This is used for partial mocking.

source

pub fn assert_called(&self, times: impl Into<Times>)

Assert the mock is called. Returns MockResult allows to call times(n) Panics if not called

source§

impl<I, O, B> MockLocator<I, O, B>
where I: 'static, O: Clone + Send + 'static,

source

pub fn returns(self, ret: O) -> Self

This makes the mock returns the given constant value. This requires Clone. For returning not clone value, use returns_once.

Auto Trait Implementations§

§

impl<I, O, B> !RefUnwindSafe for MockLocator<I, O, B>

§

impl<I, O, B> !Send for MockLocator<I, O, B>

§

impl<I, O, B> !Sync for MockLocator<I, O, B>

§

impl<I, O, B> Unpin for MockLocator<I, O, B>

§

impl<I, O, B> !UnwindSafe for MockLocator<I, O, B>

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.