James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #include <TachSensor.hpp> |
| 2 | #include <Thresholds.hpp> |
| 3 | #include <dbus/connection.hpp> |
James Feist | 582be09 | 2018-11-27 10:54:59 -0800 | [diff] [blame] | 4 | #include <nlohmann/json.hpp> |
| 5 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 6 | #include <fstream> |
| 7 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame^] | 8 | #include <gtest/gtest.h> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 9 | |
| 10 | TEST(TachSensor, TestTachSensor) |
| 11 | { |
| 12 | boost::asio::io_service io; |
| 13 | auto system_bus = |
| 14 | std::make_shared<dbus::connection>(io, dbus::bus::session); |
| 15 | dbus::DbusObjectServer object_server(system_bus); |
| 16 | |
| 17 | std::vector<thresholds::Threshold> sensor_thresholds; |
| 18 | auto t = thresholds::Threshold(thresholds::Level::CRITICAL, |
| 19 | thresholds::Direction::LOW, 1000); |
| 20 | sensor_thresholds.emplace_back(t); |
| 21 | |
| 22 | std::ofstream test_file("test.txt"); |
| 23 | test_file << "10000\n"; |
| 24 | test_file.close(); |
| 25 | auto filename = std::string("test.txt"); |
| 26 | auto fanname = std::string("test fan"); |
| 27 | TachSensor test(filename, object_server, system_bus, io, fanname, |
| 28 | std::move(sensor_thresholds)); |
| 29 | std::remove("test.txt"); |
| 30 | } |