eive-obsw/unittest/mocks/EventManagerMock.cpp
Robin Mueller 2a84ebba57
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
fix for unittest
2023-03-10 19:13:01 +01:00

64 lines
2.3 KiB
C++

#include "EventManagerMock.h"
#include <fsfw/ipc/QueueFactory.h>
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER, 80) {}
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;
}