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 namespace phosphor
10 {
11 namespace time
12 {
13 
14 class TestManager : public testing::Test
15 {
16   public:
17     sdbusplus::bus_t bus;
18     Manager manager;
19 
TestManager()20     TestManager() : bus(sdbusplus::bus::new_default()), manager(bus) {}
21 
notifyPropertyChanged(const std::string & key,const std::string & value)22     void notifyPropertyChanged(const std::string& key, const std::string& value)
23     {
24         manager.onPropertyChanged(key, value);
25     }
26 };
27 
TEST_F(TestManager,propertyChanged)28 TEST_F(TestManager, propertyChanged)
29 {
30     notifyPropertyChanged(
31         "TimeSyncMethod",
32         "xyz.openbmc_project.Time.Synchronization.Method.Manual");
33     EXPECT_EQ(Mode::Manual, manager.getTimeMode());
34 
35     notifyPropertyChanged(
36         "TimeSyncMethod",
37         "xyz.openbmc_project.Time.Synchronization.Method.NTP");
38     EXPECT_EQ(Mode::NTP, manager.getTimeMode());
39 
40     ASSERT_DEATH(notifyPropertyChanged("invalid property", "whatever"), "");
41 }
42 
43 } // namespace time
44 } // namespace phosphor
45