Struct unimock::build::QuantifiedResponse
source · [−]pub struct QuantifiedResponse<'p, F: MockFn, O, R> { /* private fields */ }
Expand description
An exactly quantified response, i.e. the number of times it is expected to respond is an exact number.
Implementations
sourceimpl<'p, F, O, R> QuantifiedResponse<'p, F, O, R> where
F: MockFn + 'static,
O: Ordering,
R: Repetition,
impl<'p, F, O, R> QuantifiedResponse<'p, F, O, R> where
F: MockFn + 'static,
O: Ordering,
R: Repetition,
sourcepub fn then(self) -> Match<'p, F, O> where
R: Repetition<Kind = Exact>,
pub fn then(self) -> Match<'p, F, O> where
R: Repetition<Kind = Exact>,
Prepare to set up a new response, which will take effect after the current response has been yielded. In order to make an output sequence, the preceding output must be exactly quantified.
sourcepub fn in_order(self) -> Clause where
O: Ordering<Kind = InOrder>,
R: Repetition<Kind = Exact>,
pub fn in_order(self) -> Clause where
O: Ordering<Kind = InOrder>,
R: Repetition<Kind = Exact>,
Turn this exactly quantified definition into a Clause expectation. The clause can be included in a sequence of ordered clauses that specify calls to different functions that must be called in the exact order specified.
Example
use unimock::*;
#[unimock]
trait Trait {
fn method(&self, arg: i32) -> &'static str;
}
let m = mock([
// the first call MUST be method(1) and it will return "a"
Trait__method.next_call(matching!(1)).returns_static("a").once().in_order(),
// the second call MUST be method(2) and it will return "b"
Trait__method.next_call(matching!(2)).returns_static("b").once().in_order(),
// there may be no more calls to this mock, as it has no stubs in it
]);
assert_eq!("a", m.method(1));
assert_eq!("b", m.method(2));
sourcepub fn in_any_order(self) -> Clause where
O: Ordering<Kind = InAnyOrder>,
pub fn in_any_order(self) -> Clause where
O: Ordering<Kind = InAnyOrder>,
Turn the call pattern into a stubbing clause, without any overall call order verification.
Auto Trait Implementations
impl<'p, F, O, R> !RefUnwindSafe for QuantifiedResponse<'p, F, O, R>
impl<'p, F, O, R> Send for QuantifiedResponse<'p, F, O, R> where
O: Send,
R: Send,
impl<'p, F, O, R> Sync for QuantifiedResponse<'p, F, O, R> where
O: Sync,
R: Sync,
impl<'p, F, O, R> Unpin for QuantifiedResponse<'p, F, O, R> where
O: Unpin,
R: Unpin,
impl<'p, F, O, R> !UnwindSafe for QuantifiedResponse<'p, F, O, R>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more