Trait mockers::Expectation
source · pub trait Expectation {
// Required methods
fn call_match(&self) -> &dyn CallMatch;
fn is_satisfied(&self) -> bool;
fn satisfy(&mut self, call: Call, mock_name: &str) -> Box<dyn Satisfy>;
fn describe(&self) -> String;
}
Expand description
Expectation is a combination of call match and corresponding action.
Expectations are built using mock handle methods:
let (mock, handle) = scenario.create_mock_for::<dyn A>();
let expectation = handle.foo().and_return(());
and are added to scenario:
scenario.expect(expectation);
Required Methods§
fn call_match(&self) -> &dyn CallMatch
fn is_satisfied(&self) -> bool
fn satisfy(&mut self, call: Call, mock_name: &str) -> Box<dyn Satisfy>
fn describe(&self) -> String
Implementors§
impl Expectation for Sequence
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Arg3: 'static, Res: 'static> Expectation for ExpectationTimes4<Arg0, Arg1, Arg2, Arg3, Res>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Arg3: 'static, Res: 'static> Expectation for ExpectationTimesSend4<Arg0, Arg1, Arg2, Arg3, Res>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Arg3: 'static, Res: 'static, F: FnOnce(Arg0, Arg1, Arg2, Arg3) -> Res + 'static> Expectation for Expectation4<Arg0, Arg1, Arg2, Arg3, Res, F>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Arg3: 'static, Res: 'static, F: FnOnce(Arg0, Arg1, Arg2, Arg3) -> Res + Send + 'static> Expectation for ExpectationSend4<Arg0, Arg1, Arg2, Arg3, Res, F>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Res: 'static> Expectation for ExpectationTimes3<Arg0, Arg1, Arg2, Res>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Res: 'static> Expectation for ExpectationTimesSend3<Arg0, Arg1, Arg2, Res>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Res: 'static, F: FnOnce(Arg0, Arg1, Arg2) -> Res + 'static> Expectation for Expectation3<Arg0, Arg1, Arg2, Res, F>
impl<Arg0: 'static, Arg1: 'static, Arg2: 'static, Res: 'static, F: FnOnce(Arg0, Arg1, Arg2) -> Res + Send + 'static> Expectation for ExpectationSend3<Arg0, Arg1, Arg2, Res, F>
impl<Arg0: 'static, Arg1: 'static, Res: 'static> Expectation for ExpectationTimes2<Arg0, Arg1, Res>
impl<Arg0: 'static, Arg1: 'static, Res: 'static> Expectation for ExpectationTimesSend2<Arg0, Arg1, Res>
impl<Arg0: 'static, Arg1: 'static, Res: 'static, F: FnOnce(Arg0, Arg1) -> Res + 'static> Expectation for Expectation2<Arg0, Arg1, Res, F>
impl<Arg0: 'static, Arg1: 'static, Res: 'static, F: FnOnce(Arg0, Arg1) -> Res + Send + 'static> Expectation for ExpectationSend2<Arg0, Arg1, Res, F>
impl<Arg0: 'static, Res: 'static> Expectation for ExpectationTimes1<Arg0, Res>
impl<Arg0: 'static, Res: 'static> Expectation for ExpectationTimesSend1<Arg0, Res>
impl<Arg0: 'static, Res: 'static, F: FnOnce(Arg0) -> Res + 'static> Expectation for Expectation1<Arg0, Res, F>
impl<Arg0: 'static, Res: 'static, F: FnOnce(Arg0) -> Res + Send + 'static> Expectation for ExpectationSend1<Arg0, Res, F>
impl<CM: CallMatch> Expectation for ExpectationNever<CM>
impl<E: Expectation> Expectation for SendWrapper<E>
SendWrapper
of any Expectation
is also Expectation
.
Scenario expects all expectations to be Send
,
and expectations produces by Send
mocks are.
Expectatinos produces by non-Send
mocks are wrapped into
SendWrapper
, which guarantee that expectation is used
from the same thread at runtime.