// tests/default/event_handler.rs use event_handlers_types::default::{CancelToken, Cancelable, EventHandler}; use futures_util::future::ready; #[test] fn event_handler_should_execute_successfully_when_not_canceled() { // Arrange: Create an executable closure that uses the mock event. let executable_closure = || -> Result<(), String> { Ok(()) }; let mut event_handler = EventHandler::new(ready(executable_closure()), CancelToken::default()); let waker = futures_util::task::noop_waker(); // Act let result = event_handler.execute(&waker); // Assert assert!(result.is_ok()); } #[test] fn event_handler_should_return_error_when_canceled() { // Arrange: Create an executable closure and a canceled CancelToken. let executable_closure = || -> Result<(), String> { Ok(()) }; let mut cancel_token = CancelToken::default(); cancel_token.cancel(); let mut event_handler = EventHandler::new(ready(executable_closure()), cancel_token); let waker = futures_util::task::noop_waker(); // Act let result = event_handler.execute(&waker); // Assert assert_eq!(result, Err("Operation was canceled.".to_string())); }