A mock implementation of ISubject for testing event-driven components.
More...
#include <MockSubject.hxx>
|
| void | attach (std::shared_ptr< IObserver > observer) override |
| | Satisfies the ISubject interface, but performs no operation.
|
| void | detach (std::shared_ptr< IObserver > observer) override |
| | Satisfies the ISubject interface, but performs no operation.
|
| void | notify (const Event &event) const override |
| | Captures the event into the internal notifications vector.
|
|
void | clear () |
| | Clears all captured notifications.
|
| bool | containsMessage (const std::string &message) const |
| | Checks if any captured notification's details contain the specified message substring.
|
| bool | containsEventType (Event::Type type) const |
| | Checks if any captured notification matches the specified Event Type.
|
| void | storeNotification (const Event &event) |
| | Stores a notification in the internal vector (alias for notify functionality).
|
|
void | clearNotifications () |
| | Clears all notifications from the internal storage.
|
| const std::vector< Event > & | getNotifications () const |
| | Returns a constant reference to the notifications vector for inspection.
|
| virtual | ~ISubject ()=default |
| | Virtual destructor.
|
|
|
std::vector< Event > | notifications |
| | Stores a history of all events received via the notify() method for assertion.
|
|
|
std::vector< IObserver * > | observers |
| | Collection of registered observers.
|
A mock implementation of ISubject for testing event-driven components.
This mock allows test cases to:
- Capture all events published via notify() method.
- Inspect captured events for specific types or messages.
- Clear the event history between test cases.
- Verify that specific events were published during execution.
◆ attach()
| void svcs::test::cli::mocks::MockSubject::attach |
( |
std::shared_ptr< IObserver > | observer | ) |
|
|
inlineoverridevirtual |
◆ containsEventType()
| bool svcs::test::cli::mocks::MockSubject::containsEventType |
( |
Event::Type | type | ) |
const |
|
inlinenodiscard |
Checks if any captured notification matches the specified Event Type.
- Parameters
-
- Returns
- true if an event of the specified type is found, false otherwise.
◆ containsMessage()
| bool svcs::test::cli::mocks::MockSubject::containsMessage |
( |
const std::string & | message | ) |
const |
|
inlinenodiscard |
Checks if any captured notification's details contain the specified message substring.
- Parameters
-
| message | The substring to search for within notification details. |
- Returns
- true if a matching message is found, false otherwise.
◆ detach()
| void svcs::test::cli::mocks::MockSubject::detach |
( |
std::shared_ptr< IObserver > | observer | ) |
|
|
inlineoverridevirtual |
◆ getNotifications()
| const std::vector< Event > & svcs::test::cli::mocks::MockSubject::getNotifications |
( |
| ) |
const |
|
inlinenodiscard |
Returns a constant reference to the notifications vector for inspection.
- Returns
- Constant reference to the vector of captured events.
◆ notify()
| void svcs::test::cli::mocks::MockSubject::notify |
( |
const Event & | event | ) |
const |
|
inlineoverridevirtual |
Captures the event into the internal notifications vector.
This is the core testing function, allowing test cases to verify that the correct events were published.
- Parameters
-
| event | The constant reference to the event structure to be captured. |
Implements svcs::services::ISubject.
◆ storeNotification()
| void svcs::test::cli::mocks::MockSubject::storeNotification |
( |
const Event & | event | ) |
|
|
inline |
Stores a notification in the internal vector (alias for notify functionality).
- Parameters
-
The documentation for this class was generated from the following file: