Skip to content

Commit fa6ff42

Browse files
committed
test: testable eventbus
1 parent 5c95727 commit fa6ff42

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

include/mock/SdkMock.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
2+
#include "../../src/eventbus/InternalEventBusFactory.h"
23
#include "ECFMP/Sdk.h"
4+
#include "ECFMP/eventbus/EventBus.h"
35
#include <gmock/gmock.h>
46

57
namespace ECFMP::Mock::Plugin {
@@ -13,8 +15,20 @@ namespace ECFMP::Mock::Plugin {
1315
);
1416
MOCK_METHOD(std::shared_ptr<const Api::EventCollection>, Events, (), (const, noexcept, override));
1517
MOCK_METHOD(std::shared_ptr<const Api::FlowMeasureCollection>, FlowMeasures, (), (const, noexcept, override));
16-
MOCK_METHOD(ECFMP::EventBus::EventBus&, EventBus, (), (const, noexcept, override));
18+
19+
[[nodiscard]] auto EventBus() const noexcept -> ECFMP::EventBus::EventBus& override
20+
{
21+
if (!eventBus) {
22+
eventBus = ECFMP::EventBus::MakeEventBus();
23+
}
24+
25+
return *eventBus;
26+
}
27+
1728
MOCK_METHOD(void, OnEuroscopeTimerTick, (), (noexcept, override));
1829
MOCK_METHOD(void, Destroy, (), (noexcept, override));
30+
31+
private:
32+
mutable std::shared_ptr<EventBus::EventBus> eventBus;
1933
};
2034
}// namespace ECFMP::Mock::Plugin

0 commit comments

Comments
 (0)