fsfw/unittests/mocks/ComIFMock.cpp

47 lines
1.2 KiB
C++
Raw Permalink Normal View History

2022-07-18 08:59:40 +02:00
#include "ComIFMock.h"
#include "DeviceHandlerMock.h"
ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {}
ComIFMock::~ComIFMock() {}
2022-08-16 01:08:26 +02:00
ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return returnvalue::OK; }
2022-07-18 08:59:40 +02:00
ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) {
data = *sendData;
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-18 08:59:40 +02:00
}
2022-08-16 01:08:26 +02:00
ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; }
2022-07-18 08:59:40 +02:00
ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) {
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-18 08:59:40 +02:00
}
ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) {
switch (testCase) {
case TestCase::MISSED_REPLY: {
*size = 0;
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-18 08:59:40 +02:00
}
case TestCase::SIMPLE_COMMAND_NOMINAL: {
*size = 1;
data = DeviceHandlerMock::SIMPLE_COMMAND_DATA;
*buffer = &data;
break;
}
case TestCase::PERIODIC_REPLY_NOMINAL: {
*size = 1;
data = DeviceHandlerMock::PERIODIC_REPLY_DATA;
*buffer = &data;
break;
}
default:
break;
}
2022-08-16 01:08:26 +02:00
return returnvalue::OK;
2022-07-18 08:59:40 +02:00
}
void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; }