pub struct MockObject { /* private fields */ }Expand description
Mock object for traits
Implementations§
Source§impl MockObject
impl MockObject
pub fn new() -> Self
Sourcepub fn record_call(&self, method_name: &str, args: Vec<String>)
pub fn record_call(&self, method_name: &str, args: Vec<String>)
Record a method call
Sourcepub fn expect(&self, expectation: Expectation)
pub fn expect(&self, expectation: Expectation)
Add an expectation
Sourcepub fn set_return<T: 'static + Send>(&self, method_name: &str, value: T)
pub fn set_return<T: 'static + Send>(&self, method_name: &str, value: T)
Set return value for a method
Sourcepub fn get_return<T: 'static>(&self, method_name: &str) -> Option<T>
pub fn get_return<T: 'static>(&self, method_name: &str) -> Option<T>
Get return value for a method
Sourcepub fn call_count(&self, method_name: &str) -> usize
pub fn call_count(&self, method_name: &str) -> usize
Get call count for a method
Sourcepub fn was_called(&self, method_name: &str) -> bool
pub fn was_called(&self, method_name: &str) -> bool
Was method called?
Sourcepub fn get_calls(&self, method_name: &str) -> Vec<MethodCall>
pub fn get_calls(&self, method_name: &str) -> Vec<MethodCall>
Get all calls for a method
Trait Implementations§
Source§impl Clone for MockObject
impl Clone for MockObject
Auto Trait Implementations§
impl Freeze for MockObject
impl RefUnwindSafe for MockObject
impl Send for MockObject
impl Sync for MockObject
impl Unpin for MockObject
impl UnsafeUnpin for MockObject
impl UnwindSafe for MockObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more