pub struct MockTracker { /* private fields */ }Expand description
A simple mock call tracker
§Example
use windjammer_runtime::mock::MockTracker;
let tracker = MockTracker::new();
tracker.record_call("my_function", vec!["arg1".to_string()]);
assert_eq!(tracker.call_count("my_function"), 1);
assert!(tracker.was_called("my_function"));Implementations§
Source§impl MockTracker
impl MockTracker
Sourcepub fn record_call(&self, function: &str, args: Vec<String>)
pub fn record_call(&self, function: &str, args: Vec<String>)
Record a function call with arguments
Sourcepub fn was_called(&self, function: &str) -> bool
pub fn was_called(&self, function: &str) -> bool
Check if a function was called
Sourcepub fn call_count(&self, function: &str) -> usize
pub fn call_count(&self, function: &str) -> usize
Get the number of times a function was called
Sourcepub fn get_calls(&self, function: &str) -> Vec<Vec<String>>
pub fn get_calls(&self, function: &str) -> Vec<Vec<String>>
Get all calls to a specific function
Sourcepub fn verify_call_count(&self, function: &str, expected: usize)
pub fn verify_call_count(&self, function: &str, expected: usize)
Verify that a function was called a specific number of times
Sourcepub fn verify_called(&self, function: &str)
pub fn verify_called(&self, function: &str)
Verify that a function was called at least once
Sourcepub fn verify_not_called(&self, function: &str)
pub fn verify_not_called(&self, function: &str)
Verify that a function was never called
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockTracker
impl RefUnwindSafe for MockTracker
impl Send for MockTracker
impl Sync for MockTracker
impl Unpin for MockTracker
impl UnsafeUnpin for MockTracker
impl UnwindSafe for MockTracker
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> 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