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

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.

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));

Turn the call pattern into a stubbing clause, without any overall call order verification.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.