created PSB mock

This commit is contained in:
Robin Müller 2022-07-26 14:10:24 +02:00
parent 75c824ec80
commit 146a0e3828
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
7 changed files with 59 additions and 2 deletions

View File

@ -7,4 +7,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
MessageQueueMock.cpp MessageQueueMock.cpp
InternalErrorReporterMock.cpp InternalErrorReporterMock.cpp
LocalPoolOwnerBase.cpp LocalPoolOwnerBase.cpp
PusVerificationReporterMock.cpp
PusServiceBaseMock.cpp
) )

View File

@ -1,5 +1,8 @@
#include "PusServiceBaseMock.h" #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) { ReturnValue_t PsbMock::handleRequest(uint8_t subservice) {
handleRequestCallCnt++; handleRequestCallCnt++;
subserviceQueue.push(subservice); subserviceQueue.push(subservice);

View File

@ -7,6 +7,7 @@
class PsbMock : public PusServiceBase { class PsbMock : public PusServiceBase {
public: public:
PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter);
unsigned int handleRequestCallCnt = 0; unsigned int handleRequestCallCnt = 0;
std::queue<uint8_t> subserviceQueue; std::queue<uint8_t> subserviceQueue;
unsigned int performServiceCallCnt = 0; unsigned int performServiceCallCnt = 0;

View 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();
}
}

View 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

View File

@ -2,4 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
testStoreHelper.cpp testStoreHelper.cpp
testSendHelper.cpp testSendHelper.cpp
testStoreAndSendHelper.cpp testStoreAndSendHelper.cpp
testPsb.cpp
) )

View File

@ -1,5 +1,9 @@
#include <catch2/catch_test_macros.hpp> #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);
}