fsfw/unittests/mocks/CfdpFaultHandlerMock.h

33 lines
1.1 KiB
C
Raw Normal View History

2022-08-09 14:55:08 +02:00
#ifndef FSFW_TESTS_CFDPFAULTHANDLERMOCK_H
#define FSFW_TESTS_CFDPFAULTHANDLERMOCK_H
#include <map>
#include <queue>
2022-08-09 15:46:42 +02:00
#include "fsfw/cfdp/handler/FaultHandlerBase.h"
2022-08-09 14:55:08 +02:00
class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase {
public:
struct FaultInfo {
size_t callCount = 0;
std::queue<cfdp::ConditionCode> condCodes;
};
void noticeOfSuspensionCb(cfdp::ConditionCode code) override;
void noticeOfCancellationCb(cfdp::ConditionCode code) override;
void abandonCb(cfdp::ConditionCode code) override;
void ignoreCb(cfdp::ConditionCode code) override;
FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode);
2022-08-09 15:09:43 +02:00
[[nodiscard]] bool faultCbWasCalled() const;
2022-08-09 14:55:08 +02:00
void reset();
private:
std::map<cfdp::FaultHandlerCodes, FaultInfo> fhInfoMap = {
std::pair{cfdp::FaultHandlerCodes::IGNORE_ERROR, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::ABANDON_TRANSACTION, FaultInfo()}};
};
#endif // FSFW_TESTS_CFDPFAULTHANDLERMOCK_H