fsfw/unittests/mocks/PusServiceBaseMock.cpp

54 lines
1.4 KiB
C++
Raw Normal View History

2022-07-26 13:59:09 +02:00
#include "PusServiceBaseMock.h"
PsbMock::PsbMock(PsbParams params) : PusServiceBase(params) {}
2022-07-26 14:10:24 +02:00
2022-07-26 13:59:09 +02:00
ReturnValue_t PsbMock::handleRequest(uint8_t subservice) {
handleRequestCallCnt++;
subserviceQueue.push(subservice);
if (handleReqFailPair.first) {
handleReqFailPair.first = false;
return handleReqFailPair.second;
}
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-26 13:59:09 +02:00
}
ReturnValue_t PsbMock::performService() {
performServiceCallCnt++;
if (performServiceFailPair.first) {
performServiceFailPair.first = false;
return performServiceFailPair.second;
}
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-26 13:59:09 +02:00
}
void PsbMock::reset() {
handleRequestCallCnt = 0;
performServiceCallCnt = 0;
std::queue<uint8_t>().swap(subserviceQueue);
}
2022-07-26 13:59:09 +02:00
void PsbMock::makeNextHandleReqCallFail(ReturnValue_t retval) {
handleReqFailPair.first = true;
handleReqFailPair.second = retval;
}
bool PsbMock::getAndPopNextSubservice(uint8_t& subservice) {
if (subserviceQueue.empty()) {
return false;
}
subservice = subserviceQueue.front();
subserviceQueue.pop();
return true;
}
2022-07-26 18:46:28 +02:00
PsbParams& PsbMock::getParams() { return psbParams; }
void PsbMock::setStaticPusDistributor(object_id_t pusDistributor) {
PUS_DISTRIBUTOR = pusDistributor;
}
object_id_t PsbMock::getStaticPusDistributor() { return PUS_DISTRIBUTOR; }
void PsbMock::setStaticTmDest(object_id_t tmDest) { PACKET_DESTINATION = tmDest; }
object_id_t PsbMock::getStaticTmDest() { return PACKET_DESTINATION; }