1 #pragma once 2 #include "network_manager.hpp" 3 4 #include <gmock/gmock.h> 5 6 namespace phosphor 7 { 8 namespace network 9 { 10 11 struct MockExecutor : DelayedExecutor 12 { 13 MOCK_METHOD((void), schedule, (), (override)); 14 MOCK_METHOD((void), setCallback, (fu2::unique_function<void()>&&), 15 (override)); 16 }; 17 18 struct TestManagerData 19 { 20 MockExecutor mockReload; 21 fu2::unique_function<void()> reloadCb; 22 reloadForManagerphosphor::network::TestManagerData23 inline MockExecutor& reloadForManager() 24 { 25 EXPECT_CALL(mockReload, setCallback(testing::_)) 26 .WillOnce([&](fu2::unique_function<void()>&& cb) { 27 reloadCb = std::move(cb); 28 }); 29 return mockReload; 30 } 31 }; 32 33 struct TestManager : TestManagerData, Manager 34 { TestManagerphosphor::network::TestManager35 inline TestManager(stdplus::PinnedRef<sdbusplus::bus_t> bus, 36 stdplus::zstring_view path, 37 const std::filesystem::path& dir) : 38 Manager(bus, reloadForManager(), path, dir) 39 {} 40 41 using Manager::handleAdminState; 42 }; 43 44 } // namespace network 45 } // namespace phosphor 46