new cfdp mock folder, added additional cfdp mocks
This commit is contained in:
1
unittests/mocks/cfdp/CMakeLists.txt
Normal file
1
unittests/mocks/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp RemoteConfigTableMock.cpp)
|
42
unittests/mocks/cfdp/FaultHandlerMock.cpp
Normal file
42
unittests/mocks/cfdp/FaultHandlerMock.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "FaultHandlerMock.h"
|
||||
|
||||
namespace cfdp {
|
||||
|
||||
void FaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) {
|
||||
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION);
|
||||
info.callCount++;
|
||||
info.condCodes.push(code);
|
||||
}
|
||||
|
||||
void FaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) {
|
||||
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
|
||||
info.callCount++;
|
||||
info.condCodes.push(code);
|
||||
}
|
||||
|
||||
void FaultHandlerMock::abandonCb(cfdp::ConditionCode code) {
|
||||
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION);
|
||||
info.callCount++;
|
||||
info.condCodes.push(code);
|
||||
}
|
||||
|
||||
void FaultHandlerMock::ignoreCb(cfdp::ConditionCode code) {
|
||||
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR);
|
||||
info.callCount++;
|
||||
info.condCodes.push(code);
|
||||
}
|
||||
|
||||
FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) {
|
||||
return fhInfoMap.at(fhCode);
|
||||
}
|
||||
|
||||
void FaultHandlerMock::reset() { fhInfoMap.clear(); }
|
||||
|
||||
bool FaultHandlerMock::faultCbWasCalled() const {
|
||||
return std::any_of(fhInfoMap.begin(), fhInfoMap.end(),
|
||||
[](const std::pair<cfdp::FaultHandlerCodes, FaultInfo>& pair) {
|
||||
return pair.second.callCount > 0;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace cfdp
|
37
unittests/mocks/cfdp/FaultHandlerMock.h
Normal file
37
unittests/mocks/cfdp/FaultHandlerMock.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef FSFW_TESTS_FAULTHANDLERMOCK_H
|
||||
#define FSFW_TESTS_FAULTHANDLERMOCK_H
|
||||
|
||||
#include <map>
|
||||
#include <queue>
|
||||
|
||||
#include "fsfw/cfdp/handler/FaultHandlerBase.h"
|
||||
|
||||
namespace cfdp {
|
||||
|
||||
class FaultHandlerMock : public FaultHandlerBase {
|
||||
public:
|
||||
struct FaultInfo {
|
||||
size_t callCount = 0;
|
||||
std::queue<cfdp::ConditionCode> condCodes;
|
||||
};
|
||||
|
||||
void noticeOfSuspensionCb(ConditionCode code) override;
|
||||
void noticeOfCancellationCb(ConditionCode code) override;
|
||||
void abandonCb(ConditionCode code) override;
|
||||
void ignoreCb(ConditionCode code) override;
|
||||
|
||||
FaultInfo& getFhInfo(FaultHandlerCodes fhCode);
|
||||
[[nodiscard]] bool faultCbWasCalled() const;
|
||||
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()}};
|
||||
};
|
||||
|
||||
} // namespace cfdp
|
||||
|
||||
#endif // FSFW_TESTS_FAULTHANDLERMOCK_H
|
6
unittests/mocks/cfdp/RemoteConfigTableMock.cpp
Normal file
6
unittests/mocks/cfdp/RemoteConfigTableMock.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "RemoteConfigTableMock.h"
|
||||
|
||||
bool cfdp::RemoteConfigTableMock::getRemoteCfg(cfdp::EntityId remoteId,
|
||||
cfdp::RemoteEntityCfg *cfg) {
|
||||
return false;
|
||||
}
|
15
unittests/mocks/cfdp/RemoteConfigTableMock.h
Normal file
15
unittests/mocks/cfdp/RemoteConfigTableMock.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H
|
||||
#define FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H
|
||||
|
||||
#include "fsfw/cfdp/handler/RemoteConfigTableIF.h"
|
||||
|
||||
namespace cfdp {
|
||||
|
||||
class RemoteConfigTableMock: public RemoteConfigTableIF {
|
||||
public:
|
||||
bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H
|
16
unittests/mocks/cfdp/UserMock.cpp
Normal file
16
unittests/mocks/cfdp/UserMock.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "UserMock.h"
|
||||
|
||||
cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {}
|
||||
|
||||
void cfdp::UserMock::transactionIndication(cfdp::TransactionId id) {}
|
||||
void cfdp::UserMock::eofSentIndication(cfdp::TransactionId id) {}
|
||||
void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code,
|
||||
uint64_t progress) {}
|
||||
void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {}
|
||||
void cfdp::UserMock::transactionFinishedIndication() {}
|
||||
void cfdp::UserMock::metadataRecvdIndication() {}
|
||||
void cfdp::UserMock::fileSegmentRecvdIndication() {}
|
||||
void cfdp::UserMock::reportIndication() {}
|
||||
void cfdp::UserMock::suspendedIndication() {}
|
||||
void cfdp::UserMock::resumedIndication() {}
|
||||
|
25
unittests/mocks/cfdp/UserMock.h
Normal file
25
unittests/mocks/cfdp/UserMock.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef FSFW_TESTS_CFDP_USERMOCK_H
|
||||
#define FSFW_TESTS_CFDP_USERMOCK_H
|
||||
|
||||
#include "fsfw/cfdp/handler/UserBase.h"
|
||||
|
||||
namespace cfdp {
|
||||
|
||||
class UserMock: public UserBase {
|
||||
explicit UserMock(HasFileSystemIF& vfs);
|
||||
public:
|
||||
void transactionIndication(TransactionId id) override;
|
||||
void eofSentIndication(TransactionId id) override;
|
||||
void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override;
|
||||
void eofRecvIndication(TransactionId id) override;
|
||||
void transactionFinishedIndication() override;
|
||||
void metadataRecvdIndication() override;
|
||||
void fileSegmentRecvdIndication() override;
|
||||
void reportIndication() override;
|
||||
void suspendedIndication() override;
|
||||
void resumedIndication() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FSFW_TESTS_CFDP_USERMOCK_H
|
Reference in New Issue
Block a user