blob: 68d5088eca671003b980e491c682bde58f9b6e76 [file] [log] [blame]
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -08001#pragma once
2#include "network_manager.hpp"
3
4#include <gmock/gmock.h>
5
6namespace phosphor
7{
8namespace network
9{
10
11struct MockExecutor : DelayedExecutor
12{
13 MOCK_METHOD((void), schedule, (), (override));
14 MOCK_METHOD((void), setCallback, (fu2::unique_function<void()> &&),
15 (override));
16};
17
18struct TestManagerData
19{
20 MockExecutor mockReload;
21 fu2::unique_function<void()> reloadCb;
22
23 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
33struct TestManager : TestManagerData, Manager
34{
William A. Kennington III9ede1b72022-11-21 01:59:28 -080035 inline TestManager(stdplus::PinnedRef<sdbusplus::bus_t> bus,
36 stdplus::zstring_view path,
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -080037 const std::filesystem::path& dir) :
38 Manager(bus, reloadForManager(), path, dir)
39 {
40 }
41
42 using Manager::handleAdminState;
43};
44
45} // namespace network
46} // namespace phosphor