| 38 | }; |
| 39 | |
| 40 | TEST(SensorList, getAsType) |
| 41 | { |
| 42 | auto handler = std::make_shared<MockHttpHandler>(); |
| 43 | HueCommandAPI commands(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); |
| 44 | |
| 45 | SensorList sensors {commands, "/sensors", std::chrono::steady_clock::duration::max()}; |
| 46 | |
| 47 | const int id = 2; |
| 48 | const nlohmann::json response = {{std::to_string(id), {{"type", "Daylight"}}}}; |
| 49 | |
| 50 | EXPECT_CALL(*handler, |
| 51 | GETJson("/api/" + getBridgeUsername() + "/sensors", nlohmann::json::object(), getBridgeIp(), getBridgePort())) |
| 52 | .WillOnce(Return(response)); |
| 53 | |
| 54 | sensors::DaylightSensor daylightSensor = sensors.getAsType<sensors::DaylightSensor>(id); |
| 55 | EXPECT_THROW(sensors.getAsType<BlaSensor>(2), HueException); |
| 56 | } |
| 57 | |
| 58 | TEST(SensorList, getAllByType) |
| 59 | { |
nothing calls this directly
no test coverage detected