[Easy-setup] Unit test case fixes for Mediator SDK
[iotivity.git] / service / easy-setup / mediator / richsdk / unittests / MediatorRichTest.cpp
index 3b0e7aa..e2b67ef 100644 (file)
@@ -227,8 +227,15 @@ TEST_F(MediatorRichTest, testStartProvisioning)
     remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn);
     remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback);
 
-    //calling the APIs
+#ifdef REMOTE_ARDUINO_ENROLEE
     EXPECT_NO_THROW(remoteEnrollee->startProvisioning());
+
+#else
+    /* It will throw the exception
+     * as it will not able to discover the provisioning resource in the network
+     */
+    EXPECT_ANY_THROW(remoteEnrollee->startProvisioning());
+#endif
 }
 
 //startProvisioning [Negative]
@@ -249,9 +256,9 @@ TEST_F(MediatorRichTest, testStartProvisioningNegative)
 
     remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn);
 
-    /*We are not registering the EasySetupStatusHandler that is why startProvisioning
-       will throw the Exception &  we are checking the same
-    */
+    /* We are not registering the EasySetupStatusHandler, so startProvisioning
+     * will throw the Exception &  we are checking the same
+     */
     EXPECT_ANY_THROW(remoteEnrollee->startProvisioning());
 }
 
@@ -274,9 +281,21 @@ TEST_F(MediatorRichTest, testStopProvisioning)
     remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn);
     remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback);
 
-    remoteEnrollee->startProvisioning();
+#ifdef REMOTE_ARDUINO_ENROLEE
+        EXPECT_NO_THROW(remoteEnrollee->startProvisioning());
+        EXPECT_NO_THROW(remoteEnrollee->stopProvisioning());
 
-    EXPECT_NO_THROW(remoteEnrollee->stopProvisioning());
+#else
+    /* It will throw the exception as
+     * it will not able to discover the provisioning resource in the network
+     */
+     EXPECT_ANY_THROW(remoteEnrollee->startProvisioning());
+
+    /* It will throw an exception
+     * as internally resource will be empty [startProvisioning is not succeed]
+     */
+    EXPECT_ANY_THROW(remoteEnrollee->stopProvisioning());
+#endif
 }
 
 //stopProvisioning [Negative]
@@ -299,8 +318,8 @@ TEST_F(MediatorRichTest, testStopProvisioningNegative)
     remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback);
 
     /* we didn't call the start provisioning API and directly calling stopProvisioning API.
-         In this case API will throw the exception & we are checking the same.
-    */
+     * In this case API will throw the exception & we are checking the same.
+     */
     EXPECT_ANY_THROW(remoteEnrollee->stopProvisioning());
 }