#pragma once #include "interfaces/sensor.hpp" #include "utils/conv_container.hpp" #include "utils/generate_unique_mock_id.hpp" #include class SensorMock : public interfaces::Sensor { public: explicit SensorMock() { initialize(); } explicit SensorMock(Id sensorId) : mockSensorId(sensorId) { initialize(); } static Id makeId(std::string_view service, std::string_view path) { return Id("SensorMock", service, path); } static std::vector> makeSensorMocks(const std::vector& sensorsInfo) { using namespace testing; std::vector>> result; for (const auto& sensorInfo : sensorsInfo) { auto& sensorMock = result.emplace_back(std::make_shared>()); ON_CALL(*sensorMock, getLabeledSensorInfo()) .WillByDefault(Return(sensorInfo)); } return utils::convContainer>( result); } MOCK_METHOD(Id, id, (), (const, override)); MOCK_METHOD(std::string, metadata, (), (const, override)); MOCK_METHOD(std::string, getName, (), (const, override)); MOCK_METHOD(void, registerForUpdates, (const std::weak_ptr&), (override)); MOCK_METHOD(void, unregisterFromUpdates, (const std::weak_ptr&), (override)); MOCK_METHOD(LabeledSensorInfo, getLabeledSensorInfo, (), (const, override)); const uint64_t mockId = generateUniqueMockId(); Id mockSensorId = Id("SensorMock", "", ""); private: void initialize() { ON_CALL(*this, id()).WillByDefault(testing::Invoke([this] { return this->mockSensorId; })); } };