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 {
|
|
|
|
|
2022-09-15 18:41:15 +02:00
|
|
|
void FaultHandlerMock::noticeOfSuspensionCb(TransactionId& id, cfdp::ConditionCode code) {
|
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION);
|
2022-08-09 14:55:08 +02:00
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-09-15 18:41:15 +02:00
|
|
|
void FaultHandlerMock::noticeOfCancellationCb(TransactionId& id, cfdp::ConditionCode code) {
|
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION);
|
2022-08-09 14:55:08 +02:00
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-09-15 18:41:15 +02:00
|
|
|
void FaultHandlerMock::abandonCb(TransactionId& id, cfdp::ConditionCode code) {
|
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::ABANDON_TRANSACTION);
|
2022-08-09 14:55:08 +02:00
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-09-15 18:41:15 +02:00
|
|
|
void FaultHandlerMock::ignoreCb(TransactionId& id, cfdp::ConditionCode code) {
|
|
|
|
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::IGNORE_ERROR);
|
2022-08-09 14:55:08 +02:00
|
|
|
info.callCount++;
|
|
|
|
info.condCodes.push(code);
|
|
|
|
}
|
|
|
|
|
2022-09-15 18:41:15 +02:00
|
|
|
FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCode 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(),
|
2022-09-15 18:41:15 +02:00
|
|
|
[](const std::pair<cfdp::FaultHandlerCode, FaultInfo>& pair) {
|
2022-08-09 14:55:08 +02:00
|
|
|
return pair.second.callCount > 0;
|
|
|
|
});
|
|
|
|
}
|
2022-08-09 19:00:47 +02:00
|
|
|
|
|
|
|
} // namespace cfdp
|