fsfw/unittests/mocks/cfdp/FaultHandlerMock.h

38 lines
1.1 KiB
C
Raw Normal View History

#ifndef FSFW_TESTS_FAULTHANDLERMOCK_H
#define FSFW_TESTS_FAULTHANDLERMOCK_H
2022-08-09 14:55:08 +02:00
#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
namespace cfdp {
class FaultHandlerMock : public FaultHandlerBase {
2022-08-09 14:55:08 +02:00
public:
struct FaultInfo {
size_t callCount = 0;
std::queue<cfdp::ConditionCode> condCodes;
};
2022-09-15 18:41:15 +02:00
void noticeOfSuspensionCb(TransactionId& id, ConditionCode code) override;
void noticeOfCancellationCb(TransactionId& id, ConditionCode code) override;
2022-09-29 16:46:55 +02:00
void abandonCb(TransactionId& id, ConditionCode code) override;
2022-09-15 18:41:15 +02:00
void ignoreCb(TransactionId& id, ConditionCode code) override;
2022-08-09 14:55:08 +02:00
2022-09-15 18:41:15 +02:00
FaultInfo& getFhInfo(FaultHandlerCode fhCode);
2022-08-09 15:09:43 +02:00
[[nodiscard]] bool faultCbWasCalled() const;
2022-08-09 14:55:08 +02:00
void reset();
private:
2022-09-15 18:41:15 +02:00
std::map<cfdp::FaultHandlerCode, FaultInfo> fhInfoMap = {
std::pair{cfdp::FaultHandlerCode::IGNORE_ERROR, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::ABANDON_TRANSACTION, FaultInfo()}};
2022-08-09 14:55:08 +02:00
};
} // namespace cfdp
#endif // FSFW_TESTS_FAULTHANDLERMOCK_H