1 #include "manager.hpp"
2 #include "mocked_property_change_listener.hpp"
3 #include "types.hpp"
4 
5 #include <sdbusplus/bus.hpp>
6 
7 #include <gtest/gtest.h>
8 
9 using ::testing::_;
10 
11 namespace phosphor
12 {
13 namespace time
14 {
15 
16 class TestManager : public testing::Test
17 {
18   public:
19     sdbusplus::bus_t bus;
20     Manager manager;
21 
22     TestManager() : bus(sdbusplus::bus::new_default()), manager(bus)
23     {}
24 
25     void notifyPropertyChanged(const std::string& key, const std::string& value)
26     {
27         manager.onPropertyChanged(key, value);
28     }
29 };
30 
31 TEST_F(TestManager, propertyChanged)
32 {
33     notifyPropertyChanged(
34         "TimeSyncMethod",
35         "xyz.openbmc_project.Time.Synchronization.Method.Manual");
36     EXPECT_EQ(Mode::Manual, manager.getTimeMode());
37 
38     notifyPropertyChanged(
39         "TimeSyncMethod",
40         "xyz.openbmc_project.Time.Synchronization.Method.NTP");
41     EXPECT_EQ(Mode::NTP, manager.getTimeMode());
42 
43     ASSERT_DEATH(notifyPropertyChanged("invalid property", "whatever"), "");
44 }
45 
46 } // namespace time
47 } // namespace phosphor
48