eive-obsw/unittest/mocks/EventManagerMock.cpp

64 lines
2.3 KiB
C++
Raw Permalink Normal View History

#include "EventManagerMock.h"
#include <fsfw/ipc/QueueFactory.h>
2023-03-10 19:13:01 +01:00
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER, 80) {}
ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
while (result == returnvalue::OK) {
EventMessage message;
result = eventReportQueue->receiveMessage(&message);
2022-08-24 17:27:47 +02:00
if (result == returnvalue::OK) {
notifyListeners(&message);
eventList.emplace_back(message);
}
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
}
const std::list<EventMessage>* EventManagerMock::getEventList() {
// call performOperation() to get all events still in the message Queue into the list
this->performOperation(0);
return &eventList;
}
void EventManagerMock::clearEventList() { // call performOperation() to get all events still in the
// message Queue into the list
this->performOperation(0);
eventList.clear();
}
bool EventManagerMock::isEventInEventList(object_id_t object, Event event) {
return isEventInEventList(object, event::getEventId(event));
}
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId) {
// call performOperation() to get all events still in the message Queue into the list
this->performOperation(0);
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
if ((iter->getReporter() == object) && (iter->getEventId() == eventId)) {
return true;
}
}
return false;
}
bool EventManagerMock::isEventInEventList(object_id_t object, Event event, uint32_t parameter1,
uint32_t parameter2) {
return isEventInEventList(object, event::getEventId(event), parameter1, parameter2);
}
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId,
uint32_t parameter1, uint32_t parameter2) {
// call performOperation() to get all events still in the message Queue into the list
this->performOperation(0);
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
if ((iter->getReporter() == object) && (iter->getEventId() == eventId) &&
(iter->getParameter1() == parameter1) && (iter->getParameter2() == parameter2)) {
return true;
}
}
return false;
2023-03-10 19:13:01 +01:00
}