1 /** 2 * Copyright © 2020 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include "action.hpp" 17 #include "mock_action.hpp" 18 #include "presence_detection.hpp" 19 20 #include <memory> 21 #include <utility> 22 #include <vector> 23 24 #include <gtest/gtest.h> 25 26 using namespace phosphor::power::regulators; 27 28 TEST(PresenceDetectionTests, Constructor) 29 { 30 std::vector<std::unique_ptr<Action>> actions{}; 31 actions.push_back(std::make_unique<MockAction>()); 32 33 PresenceDetection presenceDetection(std::move(actions)); 34 EXPECT_EQ(presenceDetection.getActions().size(), 1); 35 } 36 37 TEST(PresenceDetectionTests, Execute) 38 { 39 // TODO: Implement test when execute() function is done 40 } 41 42 TEST(PresenceDetectionTests, GetActions) 43 { 44 std::vector<std::unique_ptr<Action>> actions{}; 45 46 MockAction* action1 = new MockAction{}; 47 actions.push_back(std::unique_ptr<MockAction>{action1}); 48 49 MockAction* action2 = new MockAction{}; 50 actions.push_back(std::unique_ptr<MockAction>{action2}); 51 52 PresenceDetection presenceDetection(std::move(actions)); 53 EXPECT_EQ(presenceDetection.getActions().size(), 2); 54 EXPECT_EQ(presenceDetection.getActions()[0].get(), action1); 55 EXPECT_EQ(presenceDetection.getActions()[1].get(), action2); 56 } 57