fsfw/unittests/cfdp/PduSenderMock.h

36 lines
897 B
C++

#pragma once
#include <deque>
#include <vector>
#include "fsfw/cfdp/handler/PduSenderIF.h"
struct SentPdu {
cfdp::PduType pduType;
std::optional<cfdp::FileDirective> fileDirective;
std::vector<uint8_t> rawPdu;
};
class PduSenderMock : public cfdp::PduSenderIF {
public:
ReturnValue_t sendPdu(cfdp::PduType pduType, std::optional<cfdp::FileDirective> fileDirective,
const uint8_t* pdu, size_t pduSize) override {
SentPdu sentPdu;
sentPdu.pduType = pduType;
sentPdu.fileDirective = fileDirective;
sentPdu.rawPdu = std::vector(pdu, pdu + pduSize);
sentPdus.push_back(sentPdu);
return returnvalue::OK;
}
std::optional<SentPdu> getNextSentPacket() {
if (sentPdus.empty()) {
return std::nullopt;
}
SentPdu nextPdu = sentPdus.front();
sentPdus.pop_front();
return nextPdu;
}
std::deque<SentPdu> sentPdus;
};