created PSB mock
This commit is contained in:
parent
75c824ec80
commit
146a0e3828
@ -7,4 +7,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
MessageQueueMock.cpp
|
||||
InternalErrorReporterMock.cpp
|
||||
LocalPoolOwnerBase.cpp
|
||||
PusVerificationReporterMock.cpp
|
||||
PusServiceBaseMock.cpp
|
||||
)
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "PusServiceBaseMock.h"
|
||||
|
||||
PsbMock::PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter)
|
||||
: PusServiceBase(0, service, apid, &verifyReporter) {}
|
||||
|
||||
ReturnValue_t PsbMock::handleRequest(uint8_t subservice) {
|
||||
handleRequestCallCnt++;
|
||||
subserviceQueue.push(subservice);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
class PsbMock : public PusServiceBase {
|
||||
public:
|
||||
PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter);
|
||||
unsigned int handleRequestCallCnt = 0;
|
||||
std::queue<uint8_t> subserviceQueue;
|
||||
unsigned int performServiceCallCnt = 0;
|
||||
|
23
unittests/mocks/PusVerificationReporterMock.cpp
Normal file
23
unittests/mocks/PusVerificationReporterMock.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "PusVerificationReporterMock.h"
|
||||
|
||||
size_t PusVerificationReporterMock::successCallCount() const { return successParams.size(); }
|
||||
size_t PusVerificationReporterMock::failCallCount() const { return failParams.size(); }
|
||||
|
||||
VerifSuccessParams& PusVerificationReporterMock::getNextSuccessCallParams() {
|
||||
return successParams.front();
|
||||
}
|
||||
|
||||
void PusVerificationReporterMock::popNextFailParams() {
|
||||
if (not failParams.empty()) {
|
||||
failParams.pop();
|
||||
}
|
||||
}
|
||||
|
||||
VerifFailureParams& PusVerificationReporterMock::getNextFailCallParams() {
|
||||
return failParams.front();
|
||||
}
|
||||
void PusVerificationReporterMock::popNextSuccessParams() {
|
||||
if (not successParams.empty()) {
|
||||
successParams.pop();
|
||||
}
|
||||
}
|
23
unittests/mocks/PusVerificationReporterMock.h
Normal file
23
unittests/mocks/PusVerificationReporterMock.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H
|
||||
#define FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "fsfw/tmtcservices/VerificationReporterIF.h"
|
||||
|
||||
class PusVerificationReporterMock : public VerificationReporterIF {
|
||||
public:
|
||||
std::queue<VerifSuccessParams> successParams;
|
||||
std::queue<VerifFailureParams> failParams;
|
||||
|
||||
[[nodiscard]] size_t successCallCount() const;
|
||||
VerifSuccessParams& getNextSuccessCallParams();
|
||||
void popNextSuccessParams();
|
||||
[[nodiscard]] size_t failCallCount() const;
|
||||
VerifFailureParams& getNextFailCallParams();
|
||||
void popNextFailParams();
|
||||
|
||||
ReturnValue_t sendSuccessReport(VerifSuccessParams params) override { return 0; }
|
||||
ReturnValue_t sendFailureReport(VerifFailureParams params) override { return 0; }
|
||||
};
|
||||
#endif // FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H
|
@ -2,4 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
testStoreHelper.cpp
|
||||
testSendHelper.cpp
|
||||
testStoreAndSendHelper.cpp
|
||||
testPsb.cpp
|
||||
)
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "mocks/PusServiceBaseMock.h"
|
||||
#include "mocks/PusVerificationReporterMock.h"
|
||||
|
||||
TEST_CASE("Pus Service Base", "[pus-service-base]") { auto psb = PusServiceBase() }
|
||||
TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
auto verificationReporter = PusVerificationReporterMock();
|
||||
auto psb = PsbMock(17, 0x02, verificationReporter);
|
||||
}
|
Loading…
Reference in New Issue
Block a user