Struct unimock::build::DefineMultipleResponses
source · Expand description
A matched call pattern, ready for defining multiple response, requiring return values to implement Clone.
Implementations§
source§impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
sourcepub fn returns<V: IntoResponseClone<F::Response>>(
self,
value: V
) -> Quantify<'p, F, O>
pub fn returns<V: IntoResponseClone<F::Response>>(
self,
value: V
) -> Quantify<'p, F, O>
source§impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
impl<'p, F, O> DefineMultipleResponses<'p, F, O>where
F: MockFn + 'static,
O: Ordering,
sourcepub fn returns_default(self) -> Quantify<'p, F, O>where
<F::Response as Respond>::Type: Default,
pub fn returns_default(self) -> Quantify<'p, F, O>where
<F::Response as Respond>::Type: Default,
Specify the response of the call pattern by calling Default::default()
.
sourcepub fn answers<C, R>(self, func: C) -> Quantify<'p, F, O>where
C: for<'i> Fn(F::Inputs<'i>) -> R + Send + Sync + 'static,
R: IntoResponseOnce<F::Response>,
pub fn answers<C, R>(self, func: C) -> Quantify<'p, F, O>where
C: for<'i> Fn(F::Inputs<'i>) -> R + Send + Sync + 'static,
R: IntoResponseOnce<F::Response>,
Specify the response of the call pattern by invoking the given closure that can then compute it based on input parameters.
sourcepub fn answers_leaked_ref<C, R, T>(self, func: C) -> Quantify<'p, F, O>where
F: MockFn<Response = StaticRef<T>>,
C: for<'i> Fn(F::Inputs<'i>) -> R + Send + Sync + 'static,
R: Borrow<T> + 'static,
T: 'static,
pub fn answers_leaked_ref<C, R, T>(self, func: C) -> Quantify<'p, F, O>where
F: MockFn<Response = StaticRef<T>>,
C: for<'i> Fn(F::Inputs<'i>) -> R + Send + Sync + 'static,
R: Borrow<T> + 'static,
T: 'static,
Specify the response of the call pattern to be a static reference to leaked memory.
The value may be based on the value of input parameters.
This version will produce a new memory leak for every invocation of the answer function.
This method should only be used when computing a reference based on input parameters is necessary, which should not be a common use case.
sourcepub fn panics(self, message: impl Into<String>) -> Quantify<'p, F, O>
pub fn panics(self, message: impl Into<String>) -> Quantify<'p, F, O>
Prevent this call pattern from succeeding by explicitly panicking with a custom message.
sourcepub fn unmocked(self) -> Quantify<'p, F, O>
pub fn unmocked(self) -> Quantify<'p, F, O>
Instruct this call pattern to invoke its corresponding unmocked
function.
For this to work, the mocked trait must be configured with an unmock_with=[..]
parameter.
If unimock doesn’t find a way to unmock the function, this will panic when the function is called.