add a gtest case into serverBuilder unittest of resource-encapsulation for testing...
authorRami Jung <rami.jung@samsung.com>
Wed, 26 Aug 2015 12:05:37 +0000 (21:05 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Thu, 27 Aug 2015 04:54:12 +0000 (04:54 +0000)
new case of  unittest : SettingNestedAttributesIsSameToGettingNestedAttributes

A RCSResourceAttributes, itself could be value of a key-value pair like int, double, string and so on.
That means developers are able to nested structure when they make key-value pairs and it is possible to set up the following hierachy in attributes.

{
 "type": "Living Colors",
 "name": "LC 1",
 "modelid": "LC0015",
 "swversion": "1.0.3",

 "state": {
    "hue": 50000,
    "on": true,
    "effect": "none",
    "alert": "none",
    "bri": 200,
    "sat": 200,
    "ct": 500,
    "reachable": true,
    "colormode": "hs"
  }
}

Change-Id: Ifdf2fb41860ad7227753677741bf79c6709fbaa6
Signed-off-by: Rami Jung <rami.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2284
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp

index 435859d..80d4c57 100644 (file)
@@ -143,6 +143,18 @@ TEST_F(ResourceObjectTest, SettingAttributesWithinGuardDoesntCauseDeadLock)
     ASSERT_EQ(value, server->getAttribute<int>(KEY));
 }
 
+TEST_F(ResourceObjectTest, SettingNestedAttributesIsSameToGettingNestedAttributes)
+{
+    RCSResourceAttributes lightAttributes;
+
+    lightAttributes["red"]=50;
+    lightAttributes["blue"]=100;
+    lightAttributes["green"]=150;
+
+    server->setAttribute(KEY, lightAttributes);
+
+    ASSERT_EQ(lightAttributes, server->getAttribute<RCSResourceAttributes>(KEY));
+}
 
 class AutoNotifyTest: public ResourceObjectTest
 {