1 #pragma once
2 
3 #include "interfaces/sensor.hpp"
4 #include "utils/generate_unique_mock_id.hpp"
5 
6 #include <gmock/gmock.h>
7 
8 class SensorMock : public interfaces::Sensor
9 {
10   public:
11     explicit SensorMock()
12     {
13         initialize();
14     }
15 
16     explicit SensorMock(Id sensorId) : mockSensorId(sensorId)
17     {
18         initialize();
19     }
20 
21     static Id makeId(std::string_view service, std::string_view path)
22     {
23         return Id("SensorMock", service, path);
24     }
25 
26     MOCK_METHOD(Id, id, (), (const, override));
27     MOCK_METHOD(void, registerForUpdates,
28                 (const std::weak_ptr<interfaces::SensorListener>&), (override));
29     MOCK_METHOD(void, unregisterFromUpdates,
30                 (const std::weak_ptr<interfaces::SensorListener>&), (override));
31 
32     const uint64_t mockId = generateUniqueMockId();
33 
34     Id mockSensorId = Id("SensorMock", "", "");
35 
36   private:
37     void initialize()
38     {
39         ON_CALL(*this, id()).WillByDefault(testing::Invoke([this] {
40             return this->mockSensorId;
41         }));
42     }
43 };
44