Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / scene-manager / unittests / SceneCollectionTest.cpp
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include "UnitTestHelper.h"
22
23 #include "SceneList.h"
24 #include "OCPlatform.h"
25
26 using namespace std;
27 using namespace OIC::Service;
28 using namespace OC;
29
30 class SceneCollectionTest: public TestWithMock
31 {
32 protected:
33     void SetUp()
34     {
35         TestWithMock::SetUp();
36         pSceneList = SceneList::getInstance();
37     }
38
39 public:
40     SceneList* pSceneList;
41     std::shared_ptr<SceneCollection> pSceneCollection;
42 };
43
44 TEST_F(SceneCollectionTest, createSceneCollectionInstanceAndSceneCollectionResource)
45 {
46     bool isNullPtr = false;
47     pSceneCollection = pSceneList->addNewSceneCollection();
48
49     if(pSceneCollection->getId() == "")
50     {
51         isNullPtr = true;
52     }
53
54     EXPECT_FALSE(isNullPtr);
55 }
56
57 TEST_F(SceneCollectionTest, getSceneCollectionInstanceAndSceneCollectionResource)
58 {
59     auto sceneCollections = pSceneList->getSceneCollections();
60     bool isNullPtr = false;
61
62     for(const auto &it : sceneCollections)
63     {
64         if(it->getId() == "")
65         {
66             isNullPtr = true;
67         }
68         ASSERT_FALSE(isNullPtr);
69     }
70 }
71
72 TEST_F(SceneCollectionTest, setAndGetSceneCollectionResourceName)
73 {
74     pSceneCollection = pSceneList->addNewSceneCollection();
75     pSceneCollection->setName("Kitchen");
76     auto sceneCollectionName = pSceneCollection->getName();
77
78     EXPECT_EQ("Kitchen", sceneCollectionName);
79 }