eive-obsw/unittest/mocks/EventManagerMock.cpp
Robin Mueller 447c4d5c88
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
all retval replacements
2022-08-24 17:27:47 +02:00

63 lines
2.3 KiB
C++

#include "EventManagerMock.h"
#include <fsfw/ipc/QueueFactory.h>
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {}
ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
ReturnValue_t result = returnvalue::OK;
while (result == returnvalue::OK) {
EventMessage message;
result = eventReportQueue->receiveMessage(&message);
if (result == returnvalue::OK) {
notifyListeners(&message);
eventList.emplace_back(message);
}
}
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;
}