2022-08-09 19:00:47 +02:00
|
|
|
#include "FaultHandlerMock.h"
|
2022-08-09 14:55:08 +02:00
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
namespace cfdp {
|
|
|
|
|
|
|
|
void FaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) {
|
2022-08-09 14:55:08 +02:00
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION);
|
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
void FaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) {
|
2022-08-09 14:55:08 +02:00
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
|
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
void FaultHandlerMock::abandonCb(cfdp::ConditionCode code) {
|
2022-08-09 14:55:08 +02:00
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION);
|
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
void FaultHandlerMock::ignoreCb(cfdp::ConditionCode code) {
|
2022-08-09 14:55:08 +02:00
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR);
|
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) {
|
2022-08-09 14:55:08 +02:00
|
|
|
return fhInfoMap.at(fhCode);
|
|
|
|
}
|
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
void FaultHandlerMock::reset() { fhInfoMap.clear(); }
|
2022-08-09 14:55:08 +02:00
|
|
|
|
2022-08-09 19:00:47 +02:00
|
|
|
bool FaultHandlerMock::faultCbWasCalled() const {
|
2022-08-09 14:55:08 +02:00
|
|
|
return std::any_of(fhInfoMap.begin(), fhInfoMap.end(),
|
|
|
|
[](const std::pair<cfdp::FaultHandlerCodes, FaultInfo>& pair) {
|
|
|
|
return pair.second.callCount > 0;
|
|
|
|
});
|
|
|
|
}
|
2022-08-09 19:00:47 +02:00
|
|
|
|
|
|
|
} // namespace cfdp
|