1*6f777cdaSGeorge Liu #include <occ_dbus.hpp>
2*6f777cdaSGeorge Liu
3*6f777cdaSGeorge Liu #include <gtest/gtest.h>
4*6f777cdaSGeorge Liu
5*6f777cdaSGeorge Liu using namespace open_power::occ::dbus;
6*6f777cdaSGeorge Liu
TEST(OccDBusSensors,MaxValue)7*6f777cdaSGeorge Liu TEST(OccDBusSensors, MaxValue)
8*6f777cdaSGeorge Liu {
9*6f777cdaSGeorge Liu std::string tmpPath = "/abc/def";
10*6f777cdaSGeorge Liu double maxValue = 100.00;
11*6f777cdaSGeorge Liu double retMaxValue = 0;
12*6f777cdaSGeorge Liu
13*6f777cdaSGeorge Liu OccDBusSensors::getOccDBus().setMaxValue(tmpPath, maxValue);
14*6f777cdaSGeorge Liu retMaxValue = OccDBusSensors::getOccDBus().getMaxValue(tmpPath);
15*6f777cdaSGeorge Liu
16*6f777cdaSGeorge Liu EXPECT_EQ(maxValue, retMaxValue);
17*6f777cdaSGeorge Liu ASSERT_THROW(OccDBusSensors::getOccDBus().getMaxValue("/abcd/"),
18*6f777cdaSGeorge Liu std::invalid_argument);
19*6f777cdaSGeorge Liu }
20*6f777cdaSGeorge Liu
TEST(OccDBusSensors,MinValue)21*6f777cdaSGeorge Liu TEST(OccDBusSensors, MinValue)
22*6f777cdaSGeorge Liu {
23*6f777cdaSGeorge Liu std::string tmpPath = "/abc/def";
24*6f777cdaSGeorge Liu double minValue = 10.00;
25*6f777cdaSGeorge Liu double retMinValue = 0;
26*6f777cdaSGeorge Liu
27*6f777cdaSGeorge Liu OccDBusSensors::getOccDBus().setMinValue(tmpPath, minValue);
28*6f777cdaSGeorge Liu retMinValue = OccDBusSensors::getOccDBus().getMinValue(tmpPath);
29*6f777cdaSGeorge Liu
30*6f777cdaSGeorge Liu EXPECT_EQ(minValue, retMinValue);
31*6f777cdaSGeorge Liu ASSERT_THROW(OccDBusSensors::getOccDBus().getMinValue("/abcd/"),
32*6f777cdaSGeorge Liu std::invalid_argument);
33*6f777cdaSGeorge Liu }
34*6f777cdaSGeorge Liu
TEST(OccDBusSensors,Value)35*6f777cdaSGeorge Liu TEST(OccDBusSensors, Value)
36*6f777cdaSGeorge Liu {
37*6f777cdaSGeorge Liu std::string tmpPath = "/abc/def";
38*6f777cdaSGeorge Liu double value = 30.00;
39*6f777cdaSGeorge Liu double retValue = 0;
40*6f777cdaSGeorge Liu
41*6f777cdaSGeorge Liu OccDBusSensors::getOccDBus().setValue(tmpPath, value);
42*6f777cdaSGeorge Liu retValue = OccDBusSensors::getOccDBus().getValue(tmpPath);
43*6f777cdaSGeorge Liu
44*6f777cdaSGeorge Liu EXPECT_EQ(value, retValue);
45*6f777cdaSGeorge Liu ASSERT_THROW(OccDBusSensors::getOccDBus().getValue("/abcd/"),
46*6f777cdaSGeorge Liu std::invalid_argument);
47*6f777cdaSGeorge Liu }
48*6f777cdaSGeorge Liu
TEST(OccDBusSensors,Unit)49*6f777cdaSGeorge Liu TEST(OccDBusSensors, Unit)
50*6f777cdaSGeorge Liu {
51*6f777cdaSGeorge Liu std::string tmpPath = "/abc/def";
52*6f777cdaSGeorge Liu const std::string unit = "xyz.openbmc_project.Sensor.Value.Unit.DegreesC";
53*6f777cdaSGeorge Liu std::string retUnit = "";
54*6f777cdaSGeorge Liu
55*6f777cdaSGeorge Liu OccDBusSensors::getOccDBus().setUnit(tmpPath, unit);
56*6f777cdaSGeorge Liu retUnit = OccDBusSensors::getOccDBus().getUnit(tmpPath);
57*6f777cdaSGeorge Liu
58*6f777cdaSGeorge Liu EXPECT_EQ(unit, retUnit);
59*6f777cdaSGeorge Liu ASSERT_THROW(OccDBusSensors::getOccDBus().getUnit("/abcd/"),
60*6f777cdaSGeorge Liu std::invalid_argument);
61*6f777cdaSGeorge Liu }
62*6f777cdaSGeorge Liu
TEST(OccDBusSensors,OperationalStatus)63*6f777cdaSGeorge Liu TEST(OccDBusSensors, OperationalStatus)
64*6f777cdaSGeorge Liu {
65*6f777cdaSGeorge Liu std::string tmpPath = "/abc/def";
66*6f777cdaSGeorge Liu bool retStatus = false;
67*6f777cdaSGeorge Liu
68*6f777cdaSGeorge Liu OccDBusSensors::getOccDBus().setOperationalStatus(tmpPath, true);
69*6f777cdaSGeorge Liu retStatus = OccDBusSensors::getOccDBus().getOperationalStatus(tmpPath);
70*6f777cdaSGeorge Liu
71*6f777cdaSGeorge Liu EXPECT_EQ(true, retStatus);
72*6f777cdaSGeorge Liu ASSERT_THROW(OccDBusSensors::getOccDBus().getOperationalStatus("/abcd/"),
73*6f777cdaSGeorge Liu std::invalid_argument);
74*6f777cdaSGeorge Liu }
75