pub struct MockWebSocketServer { /* private fields */ }Expand description
Mock WebSocket server for testing
Implementations§
Source§impl MockWebSocketServer
impl MockWebSocketServer
pub fn new(config: MockConfig) -> Self
Sourcepub fn add_response(&self, request_key: &str, response: Value)
pub fn add_response(&self, request_key: &str, response: Value)
Add a mock response for a specific request pattern
Sourcepub fn add_response_with_delay(
&self,
request_key: &str,
response: Value,
delay_ms: u64,
)
pub fn add_response_with_delay( &self, request_key: &str, response: Value, delay_ms: u64, )
Add a mock response with custom delay
Sourcepub fn get_sent_messages(&self) -> Vec<Value>
pub fn get_sent_messages(&self) -> Vec<Value>
Get all sent messages for verification
Sourcepub fn clear_sent_messages(&self)
pub fn clear_sent_messages(&self)
Clear sent message history
Sourcepub async fn process_message(
&self,
message: Message,
) -> ObnizResult<Option<Value>>
pub async fn process_message( &self, message: Message, ) -> ObnizResult<Option<Value>>
Mock WebSocket message processing
Sourcepub async fn trigger_callback(&self, key: &str, data: Value)
pub async fn trigger_callback(&self, key: &str, data: Value)
Simulate callback events
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockWebSocketServer
impl RefUnwindSafe for MockWebSocketServer
impl Send for MockWebSocketServer
impl Sync for MockWebSocketServer
impl Unpin for MockWebSocketServer
impl UnsafeUnpin for MockWebSocketServer
impl UnwindSafe for MockWebSocketServer
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