pub struct ComponentTestHarness<C: Component> { /* private fields */ }Expand description
Test harness for Component implementations.
Provides a minimal testing environment for components without requiring OrcsEngine or EventBus.
Implementations§
Source§impl<C: Component> ComponentTestHarness<C>
impl<C: Component> ComponentTestHarness<C>
Sourcepub fn component_mut(&mut self) -> &mut C
pub fn component_mut(&mut self) -> &mut C
Returns a mutable reference to the component under test.
Sourcepub fn init(&mut self) -> Result<(), ComponentError>
pub fn init(&mut self) -> Result<(), ComponentError>
Calls init() on the component with an empty config.
§Errors
Returns the component’s initialization error if any.
Sourcepub fn init_with_config(&mut self, config: &Value) -> Result<(), ComponentError>
pub fn init_with_config(&mut self, config: &Value) -> Result<(), ComponentError>
Calls init() on the component with the given config.
§Errors
Returns the component’s initialization error if any.
Sourcepub fn send_request(
&mut self,
request: &Request,
) -> Result<Value, ComponentError>
pub fn send_request( &mut self, request: &Request, ) -> Result<Value, ComponentError>
Sourcepub fn request(
&mut self,
category: EventCategory,
operation: &str,
payload: Value,
) -> Result<Value, ComponentError>
pub fn request( &mut self, category: EventCategory, operation: &str, payload: Value, ) -> Result<Value, ComponentError>
Sourcepub fn send_signal(&mut self, signal: Signal) -> SignalResponse
pub fn send_signal(&mut self, signal: Signal) -> SignalResponse
Sourcepub fn veto(&mut self) -> SignalResponse
pub fn veto(&mut self) -> SignalResponse
Sourcepub fn cancel(&mut self) -> SignalResponse
pub fn cancel(&mut self) -> SignalResponse
Sourcepub fn cancel_channel(&mut self, channel: ChannelId) -> SignalResponse
pub fn cancel_channel(&mut self, channel: ChannelId) -> SignalResponse
Sourcepub fn approve(&mut self, approval_id: &str) -> SignalResponse
pub fn approve(&mut self, approval_id: &str) -> SignalResponse
Sourcepub fn id(&self) -> &ComponentId
pub fn id(&self) -> &ComponentId
Returns the component ID.
Sourcepub fn request_log(&self) -> &[RequestRecord]
pub fn request_log(&self) -> &[RequestRecord]
Returns the request log for snapshot testing.
Sourcepub fn signal_log(&self) -> &[SignalRecord]
pub fn signal_log(&self) -> &[SignalRecord]
Returns the signal log for snapshot testing.
Sourcepub fn clear_logs(&mut self)
pub fn clear_logs(&mut self)
Clears all logs.
Sourcepub fn test_channel(&self) -> ChannelId
pub fn test_channel(&self) -> ChannelId
Returns the test channel ID.
Sourcepub fn with_channel(self, channel: ChannelId) -> Self
pub fn with_channel(self, channel: ChannelId) -> Self
Sets a custom test channel ID.
Auto Trait Implementations§
impl<C> Freeze for ComponentTestHarness<C>where
C: Freeze,
impl<C> RefUnwindSafe for ComponentTestHarness<C>where
C: RefUnwindSafe,
impl<C> Send for ComponentTestHarness<C>
impl<C> Sync for ComponentTestHarness<C>
impl<C> Unpin for ComponentTestHarness<C>where
C: Unpin,
impl<C> UnsafeUnpin for ComponentTestHarness<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for ComponentTestHarness<C>where
C: UnwindSafe,
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