--- /dev/null
+
+ifndef config
+ config=debug
+endif
+
+ifndef verbose
+ SILENT = @
+endif
+
+PROJECTS := tct-iotconnectivity-tizen-tests
+
+CSC = mcs
+
+.PHONY: all clean help $(PROJECTS) prebuild prelink
+
+ifeq ($(config),debug)
+ FLAGS = /debug /noconfig /d:DEBUG
+endif
+
+ifeq ($(config),release)
+ FLAGS = /optimize /noconfig /d:NDEBUG
+endif
+
+FLAGS += /t:exe
+
+TARGETDIR = bin
+OBJDIR = obj
+TARGET = $(TARGETDIR)/$(PROJECTS).exe
+SOURCES = $(wildcard src/**/*.cs src/*.cs)
+null :=
+space := $(null) #
+comma := ,
+DLLS = $(wildcard lib/*.dll)
+ifneq ("$(DLLS)", "")
+ REFERENCE = "/reference:$(subst $(space),$(comma),$(DLLS))"
+endif
+
+all: $(TARGETDIR) $(TARGET)
+
+$(TARGET): $(SOURCES) $(DLLS)
+ @echo "=== Building $(PROJECTS) ($(config))"
+ $(SILENT) $(CSC) /nologo /out:$@ $(REFERENCE) $(FLAGS) $(SOURCES)
+
+$(TARGETDIR):
+ $(SILENT) mkdir -p $(TARGETDIR)
+
+clean:
+ $(SILENT) rm -rf $(TARGETDIR)
--- /dev/null
+tct-suite-tizen-tests
+├── src - Directory containing main method and test cases.
+│ ├── Program.cs - Main method of the application.
+│ ├── testcase
+│ │ ├── TSApplicationManager.cs - Test case file of ApplicationManager Class.
+│ │ └── …… - Other test case files.
+│ └── support
+│ └── ApplicationCommon.cs - A Support file which supports test cases.
+├── bin - Contains executable file which is created by make file.
+├── lib - Library files which needs to be packed.
+├── res - Resource folder for any resources needed to run test.
+├── share
+├── Makefile - Script which builds package.
+├── TCTCert.p12 - A Certificate file for building package. (pw:test)
+└── tizen-manifest.xml - A Tizen Manifest file for declaring privilege and controls.
--- /dev/null
+# Naming conventions
+
+1) "TC" refers to "org.test.tizen.tizen".
+
+# purpose of those scripts
+
+1) "push.sh" - this script is made for pushing the TC and "install.sh", "run.sh" scripts to Tizen device. Run it in Ubuntu.
+
+2) "install.sh" - this script is made for installing the test application in Tizen device. This script will be pushed to "/home/owner" directory of Tizen device. Manually run it.
+
+3) "run.sh" - this script is made for launching & relaunching TC for API. This script will be pushed to "/home/owner" directory of Tizen device. Manually run it.
--- /dev/null
+pkgcmd -u -n org.test.iotconnectivity.tizen
+pkgcmd -t tpk -i -p org.test.iotconnectivity.tizen.tpk -q
--- /dev/null
+# pull result file
+sdb root on
+sdb pull /home/owner/share/IoTServerManagerT/IoTServerManagerT.xml Result/
+sdb pull /home/owner/share/IoTServerManagerT/summary.xml Result/
+sdb pull /home/owner/share/IoTClientManagerT/IoTClientManagerT.xml Result/
+sdb pull /home/owner/share/IoTClientManagerT/summary.xml Result/
+sdb pull /home/owner/share/ResourceOptionsT/ResourceOptionsT.xml Result/
+sdb pull /home/owner/share/ResourceOptionsT/summary.xml Result/
+sdb pull /home/owner/share/ResourceQueryT/ResourceQueryT.xml Result/
+sdb pull /home/owner/share/ResourceQueryT/summary.xml Result/
+sdb pull /home/owner/share/ResourceTypesT/ResourceTypesT.xml Result/
+sdb pull /home/owner/share/ResourceTypesT/summary.xml Result/
+sdb pull /home/owner/share/AttributesT/AttributesT.xml Result/
+sdb pull /home/owner/share/AttributesT/summary.xml Result/
+sdb pull /home/owner/share/LiteResourceT/LiteResourceT.xml Result/
+sdb pull /home/owner/share/LiteResourceT/summary.xml Result/
+sdb pull /home/owner/share/RepresentationT/RepresentationT.xml Result/
+sdb pull /home/owner/share/RepresentationT/summary.xml Result/
+sdb pull /home/owner/share/ResourceInterfacesT/ResourceInterfacesT.xml Result/
+sdb pull /home/owner/share/ResourceInterfacesT/summary.xml Result/
+sdb pull /home/owner/share/RemoteResourceT/RemoteResourceT.xml Result/
+sdb pull /home/owner/share/RemoteResourceT/summary.xml Result/
+sdb pull /home/owner/share/ResourceFoundEventArgsT/ResourceFoundEventArgsT.xml Result/
+sdb pull /home/owner/share/ResourceFoundEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/CacheUpdatedEventArgsT/CacheUpdatedEventArgsT.xml Result/
+sdb pull /home/owner/share/CacheUpdatedEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/DeviceInformationFoundEventArgsT/DeviceInformationFoundEventArgsT.xml Result/
+sdb pull /home/owner/share/DeviceInformationFoundEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/FindingErrorOccurredEventArgsT/FindingErrorOccurredEventArgsT.xml Result/
+sdb pull /home/owner/share/FindingErrorOccurredEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/ObserverNotifiedEventArgsT/ObserverNotifiedEventArgsT.xml Result/
+sdb pull /home/owner/share/ObserverNotifiedEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/PlatformInformationFoundEventArgsT/PlatformInformationFoundEventArgsT.xml Result/
+sdb pull /home/owner/share/PlatformInformationFoundEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/PresenceReceivedEventArgsT/PresenceReceivedEventArgsT.xml Result/
+sdb pull /home/owner/share/PresenceReceivedEventArgsT/summary.xml Result/
+sdb pull /home/owner/share/StateChangedEventArgsT/StateChangedEventArgsT.xml Result/
+sdb pull /home/owner/share/StateChangedEventArgsT/summary.xml Result/
--- /dev/null
+sdb root on
+sdb push ../org.test.iotconnectivity.tizen.tpk install.sh run.sh /home/owner
--- /dev/null
+# install & run TC
+app_launcher -s org.test.iotconnectivity.tizen
--- /dev/null
+using Tizen.Applications;\r
+\r
+namespace TestFramework {\r
+ public class MyApplication : UIApplication {\r
+ protected override void OnCreate() {\r
+ Assert.Init();\r
+ TestManager manager = new TestManager();\r
+ manager.RunTestFromTCList();\r
+ }\r
+\r
+ protected override void OnResume() {\r
+ LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Resumed!");\r
+ }\r
+\r
+ protected override void OnPause() {\r
+ LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Paused!");\r
+ }\r
+\r
+ protected override void OnTerminate() {\r
+ LogUtils.write(LogUtils.DEBUG, LogUtils.INFO, "Terminated!");\r
+ }\r
+ }\r
+ class Program {\r
+ static void Main(string[] args) {\r
+ MyApplication app = new MyApplication();\r
+ app.Run(args);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.CacheUpdatedEventArgsT {
+
+ [TestFixture]
+ [Description("Test class to test CacheUpdatedEventArgs class")]
+ public class CacheUpdatedEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "CacheUpdatedEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "CacheUpdatedEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of CacheUpdatedEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.CacheUpdatedEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void CacheUpdatedEventArgs_INIT() {
+ var cacheUpdatedEventArgs = new CacheUpdatedEventArgs();
+ Assert.IsInstanceOf<CacheUpdatedEventArgs>(cacheUpdatedEventArgs);
+ Assert.IsNotNull(cacheUpdatedEventArgs, "CacheUpdatedEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.IoTClientManagerT {
+
+ [TestFixture]
+ [Description("Class to test Client manager")]
+ public class ClientManagerTest {
+ private static bool bFlag;
+ private static string TAG = "IOT-TEST";
+ private static string APP_SERVER_ID = "org.tizen.IoTServerApp";
+ private static string APP_SERVER_IP = null;//172.16.5.240:58119
+ private static int i=1;
+
+ public static async Task waitFlag() {
+ int count = 0;
+ while (true) {
+ Log.Info(TAG, "Waiting..................................................");
+ await Task.Delay(5000);
+ count++;
+ if (bFlag) break;
+ if (count == 5) break;
+ }
+ }
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ClientManagerTest Init :" + i);
+ bFlag = false;
+ var appInfor = new ApplicationInfo(APP_SERVER_ID);
+ if (!appInfor.IsRunning)
+ {
+ Log.Info(TAG, "ClientManagerTest Init launching server");
+ AppControl apCtrl = new AppControl();
+ apCtrl.ApplicationId = APP_SERVER_ID;
+ AppControl.SendLaunchRequest(apCtrl);
+ }
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ClientManagerTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Initialize IOT Client Manager")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.Initialize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.Initialize();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Denitialize IOT Client Manager")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.Deinitialize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Deinitialize_CHANGE_STATUS() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.Deinitialize();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("TimeOut property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.TimeOut A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void TimeOut_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.TimeOut = 120;
+ var timeOut = IoTConnectivityClientManager.TimeOut;
+ Assert.AreEqual(timeOut, 120, "Getter value should not be different from what was set");
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("PollingInterval property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.PollingInterval A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void PollingInterval_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.PollingInterval = 100;
+ var interval = IoTConnectivityClientManager.PollingInterval;
+ Assert.AreEqual(interval, 100, "Getter value should not be different from what was set");
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Invokes next message from queue")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.InvokePolling M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void InvokePolling_MR() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.InvokePolling();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Starts receiving presence events")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.StartReceivingPresence E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StartReceivingPresence_CHECK_EVENT() {
+ /*
+ * PRECONDITION
+ */
+ Log.Info(TAG, "StartReceivingPresence");
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.PresenceReceived += (object sender, PresenceReceivedEventArgs e) =>
+ {
+ Log.Info(TAG, "PresenceReceived, presence id :"+ e.PresenceId);
+ bFlag = true;
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Log.Info(TAG, "StartReceivingPresence got error");
+ bFlag = false;
+ };
+ id = IoTConnectivityClientManager.StartReceivingPresence(APP_SERVER_IP, "oic.iot.door");
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid presence id");
+ Assert.True(bFlag, "Did not receive presence received event");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.StopReceivingPresence(id);
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Stops receiving presence events")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.StopReceivingPresence M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StopReceivingPresence_CHECK_EVENT() {
+ Log.Info(TAG, "StopReceivingPresence");
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+ IoTConnectivityClientManager.PresenceReceived += (object sender, PresenceReceivedEventArgs e) =>
+ {
+ Log.Info(TAG, "PresenceReceived, presence id :"+ e.PresenceId);
+ if (e.PresenceId == id)
+ bFlag = true;
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Log.Info(TAG, "StopReceivingPresence got error");
+ bFlag = false;
+ };
+ id = IoTConnectivityClientManager.StartReceivingPresence(APP_SERVER_IP, "oic.iot.door");
+ await waitFlag();
+
+ /* TEST CODE */
+ try
+ {
+ if (bFlag)
+ IoTConnectivityClientManager.StopReceivingPresence(id);
+ else
+ Assert.True(false, "Presence callback were never received");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Starts finding resource events")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.StartFindingResource E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StartFindingResource_CHECK_EVENT() {
+ Log.Info(TAG, "StartFindingResource");
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ Log.Info(TAG, "ResourceFound, request id :"+ e.RequestId);
+ if (e.RequestId == id)
+ bFlag = true;
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Log.Info(TAG, "StartFindingResource got error");
+ bFlag = false;
+ };
+ id = IoTConnectivityClientManager.StartFindingResource(APP_SERVER_IP, "oic.iot.door");
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Starts finding device information")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.StartFindingDeviceInformation E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StartFindingDeviceInformation_CHECK_EVENT() {
+ Log.Info(TAG, "StartFindingDeviceInformation");
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.DeviceInformationFound += (object sender, DeviceInformationFoundEventArgs e) =>
+ {
+ Log.Info(TAG, "DeviceInformationFound, request id:"+ e.RequestId);
+ if (e.RequestId == id)
+ bFlag = true;
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Log.Info(TAG, "StartFindingDeviceInformation got error");
+ bFlag = false;
+ };
+ id = IoTConnectivityClientManager.StartFindingDeviceInformation(APP_SERVER_IP);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive device information found event");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Starts finding platform information")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityClientManager.StartFindingPlatformInformation E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StartFindingPlatformInformation_CHECK_EVENT() {
+ Log.Info(TAG, "StartFindingPlatformInformation");
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityClientManager.PlatformInformationFound += (object sender, PlatformInformationFoundEventArgs e) =>
+ {
+ Log.Info(TAG, "PlatformInformationFound :"+ e.RequestId);
+ if (e.RequestId == id)
+ bFlag = true;
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Log.Info(TAG, "StartFindingPlatformInformation got error");
+ bFlag = false;
+ };
+ id = IoTConnectivityClientManager.StartFindingPlatformInformation(APP_SERVER_IP);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive platform information found event");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ IoTConnectivityClientManager.Deinitialize();
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.DeviceInformationFoundEventArgsT {
+
+ [TestFixture]
+ [Description("Class to test DeviceInformationFoundEventArgs class")]
+ public class DeviceInformationFoundEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "DeviceInformationFoundEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "DeviceInformationFoundEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of DeviceInformationFoundEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.DeviceInformationFoundEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void DeviceInformationFoundEventArgs_INIT() {
+ var deviceInformationFoundEventArgs = new DeviceInformationFoundEventArgs();
+ Assert.IsInstanceOf<DeviceInformationFoundEventArgs>(deviceInformationFoundEventArgs);
+ Assert.IsNotNull(deviceInformationFoundEventArgs, "DeviceInformationFoundEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.FindingErrorOccurredEventArgsT {
+
+ [TestFixture]
+ [Description("Class to test FindingErrorOccurredEventArgs class")]
+ public class FindingErrorOccurredEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "FindingErrorOccurredEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "FindingErrorOccurredEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of FindingErrorOccurredEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.FindingErrorOccurredEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void FindingErrorOccurredEventArgs_INIT() {
+ var findingErrorOccurredEventArgs = new FindingErrorOccurredEventArgs();
+ Assert.IsInstanceOf<FindingErrorOccurredEventArgs>(findingErrorOccurredEventArgs);
+ Assert.IsNotNull(findingErrorOccurredEventArgs, "FindingErrorOccurredEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.LiteResourceT {
+
+ [TestFixture]
+ [Description("Class to test LiteResource")]
+ public class LiteResourceTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "LiteResourceTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "LiteResourceTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Constructor of LiteResource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.LiteResource M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ try
+ {
+ Attributes attributes = new Attributes()
+ {
+ {"state", "ON"}
+ };
+ List<string> list = new List<string>()
+ {
+ "org.tizen.light"
+ };
+ LiteResource res = new LiteResource("/light/1", new ResourceTypes(list), ResourcePolicy.Discoverable, attributes);
+ Assert.IsNotNull(res, "LiteResource should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Attributes property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.LiteResource.Attributes A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Attributes_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ List<string> list = new List<string>()
+ {
+ "org.tizen.light"
+ };
+ List<int> data = new List<int>(){ 1, 2, 3, 4, 5 };
+ LiteResource res = new LiteResource("/light/1", new ResourceTypes(list), ResourcePolicy.Discoverable);
+ Attributes newAttributes = new Attributes {
+ { "state", "ON" },
+ { "dim", 10 },
+ { "data", data },
+ {"resourceState", new Attributes {
+ { "Bright", 10 }
+ }
+ }
+ };
+
+ /* TEST CODE */
+ try
+ {
+ res.Attributes = newAttributes;
+ var attributes = res.Attributes;
+ Assert.AreEqual(attributes, newAttributes, "Getter value should not be different from what was set");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ObserverNotifiedEventArgsT {
+
+ [TestFixture]
+ [Description("Test class to test ObserverNotifiedEventArgs class")]
+ public class ObserverNotifiedEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ObserverNotifiedEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ObserverNotifiedEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of ObserverNotifiedEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.ObserverNotifiedEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ObserverNotifiedEventArgs_INIT() {
+ var observerNotifiedEventArgs = new ObserverNotifiedEventArgs();
+ Assert.IsInstanceOf<ObserverNotifiedEventArgs>(observerNotifiedEventArgs);
+ Assert.IsNotNull(observerNotifiedEventArgs, "ObserverNotifiedEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.PlatformInformationFoundEventArgsT {
+
+ [TestFixture]
+ [Description("Test class to test PlatformInformationFoundEventArgs class")]
+ public class PlatformInformationFoundEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "PlatformInformationFoundEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "PlatformInformationFoundEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of PlatformInformationFoundEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.PlatformInformationFoundEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void PlatformInformationFoundEventArgs_INIT() {
+ var platformInformationFoundEventArgs = new PlatformInformationFoundEventArgs();
+ Assert.IsInstanceOf<PlatformInformationFoundEventArgs>(platformInformationFoundEventArgs);
+ Assert.IsNotNull(platformInformationFoundEventArgs, "PlatformInformationFoundEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.PresenceReceivedEventArgsT {
+
+ [TestFixture]
+ [Description("Test class to test PresenceReceivedEventArgs class")]
+ public class PresenceReceivedEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "PresenceReceivedEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "PresenceReceivedEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of PresenceReceivedEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.PresenceReceivedEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void PresenceReceivedEventArgs_INIT() {
+ var presenceReceivedEventArgs = new PresenceReceivedEventArgs();
+ Assert.IsInstanceOf<PresenceReceivedEventArgs>(presenceReceivedEventArgs);
+ Assert.IsNotNull(presenceReceivedEventArgs, "PresenceReceivedEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.RemoteResourceT {
+
+ [TestFixture]
+ [Description("Class to test RemoteResource APIs")]
+ public class RemoteResourceTest {
+ private static bool bFlag;
+ private static string TAG = "IOT-TEST";
+ private static string APP_SERVER_ID = "org.tizen.IoTServerApp";
+ private static string RESOURCE_TYPE = "oic.iot.door";
+ private static string RESOURCE_TYPE2 = "oic.iot.door2";
+ private static string APP_SERVER_IP = "172.16.5.240";
+ private static string DOOR_URI = "/door/uri1";
+ private static string DOOR_URI2 = "/door/uri2";
+ private const string DOOR_ATTRIBUTE = "DOOR_ATTRIBUTE";
+ private static string LIGHT_URI = "/light/uri1";
+ private const string LIGHT_ATTRIBUTE = "LIGHT_ATTRIBUTE";
+ private static string hostAddress = null;
+ private static int i = 1;
+
+ public static async Task waitFlag() {
+ int count = 0;
+ while (true) {
+ Log.Info(TAG, "Waiting..................................................");
+ await Task.Delay(1000);
+ count++;
+ if (bFlag) break;
+ if (count == 10) break;
+ }
+ }
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "RemoteResourceTest Init :" + i);
+ bFlag = false;
+ var appInfor = new ApplicationInfo(APP_SERVER_ID);
+ if (!appInfor.IsRunning)
+ {
+ Log.Info(TAG, "RemoteResourceTest Init launching server");
+ AppControl apCtrl = new AppControl();
+ apCtrl.ApplicationId = APP_SERVER_ID;
+ AppControl.SendLaunchRequest(apCtrl);
+ }
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "RemoteResourceTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Constructor of RemoteResource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+
+ //Test code
+ try
+ {
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Discoverable | ResourcePolicy.Observable, types, ifaces);
+ Assert.IsNotNull(res, "RemoteResource should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource HostAddress property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.HostAddress A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void HostAddress_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Discoverable | ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ var host = res.HostAddress;
+ Assert.AreEqual(host, APP_SERVER_IP, "Host address is incorrect");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource UriPath property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.UriPath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void UriPath_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ var uri = res.UriPath;
+ Assert.AreEqual(uri, DOOR_URI, "Uri path is incorrect");
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource Types property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.Types A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Types_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ types.Add("oic.iot.light");
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ var newTypes = res.Types;
+ Assert.AreEqual(newTypes.ElementAt(0), RESOURCE_TYPE, "Type is incorrect");
+ Assert.AreEqual(newTypes.ElementAt(1), "oic.iot.light", "Type is incorrect");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource Interfaces property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.Interfaces A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Interfaces_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ ifaces.Add(ResourceInterfaces.LinkInterface);
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ var newIfaces = res.Interfaces;
+ Assert.AreEqual(newIfaces.ElementAt(0), ResourceInterfaces.BatchInterface, "Interfaces is incorrect");
+ Assert.AreEqual(newIfaces.ElementAt(1), ResourceInterfaces.LinkInterface, "Interfaces is incorrect");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource Policy property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.Policy A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Policy_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ var policy = res.Policy;
+ Assert.IsTrue(policy==ResourcePolicy.Observable, "Policy is incorrect");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource DeviceName property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.DeviceName A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task DeviceName_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + e.Resource.HostAddress);
+ Assert.AreEqual(e.Resource.DeviceName, "TestTizenDevice", "Device name is not correct");
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ Log.Info(TAG, "Start finding resource");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Options property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.Options A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Options_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, DOOR_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ try
+ {
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ res.Options = options;
+ var newOptions = res.Options;
+ Assert.AreEqual(options, newOptions, "Getter value should not be different from what was set");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource CachedRepresentation property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.CachedRepresentation M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task CachedRepresentation_RETURN() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+ RemoteResource resource = null;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress + ", uri :" + e.Resource.UriPath);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ resource = e.Resource;
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ bFlag = false;
+
+ resource.CacheUpdated += (object sender, CacheUpdatedEventArgs e) =>
+ {
+ Log.Info(TAG, "CacheUpdated event received, new attribute:" + e.Representation.Attributes[DOOR_ATTRIBUTE]);
+ bFlag = true;
+ };
+ resource.CacheEnabled = true;
+
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await resource.PutAsync(repr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+
+ await waitFlag();
+ Assert.True(bFlag, "Did not receive cache updated event");
+ Assert.IsTrue((int)(resource.CachedRepresentation().Attributes[DOOR_ATTRIBUTE]) == 4, "Cached representation attribute is not correct");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource CacheEnabled property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.CacheEnabled A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task CacheEnabled_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+ RemoteResource resource = null;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress + ", uri :" + e.Resource.UriPath);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ resource = e.Resource;
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ bFlag = false;
+
+ resource.CacheUpdated += (object sender, CacheUpdatedEventArgs e) =>
+ {
+ Log.Info(TAG, "CacheUpdated event received, new attribute:" + e.Representation.Attributes[DOOR_ATTRIBUTE]);
+ bFlag = true;
+ Assert.IsTrue((int)(e.Representation.Attributes[DOOR_ATTRIBUTE]) == 4, "New representation attribute is not correct");
+ };
+ resource.CacheEnabled = true;
+
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await resource.PutAsync(repr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+
+ //await waitFlag();
+ Assert.True(bFlag, "Did not receive cache updated event");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource TimeInterval property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.TimeInterval A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void TimeInterval_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ List<string> list = new List<string>()
+ {
+ RESOURCE_TYPE
+ };
+ ResourceTypes types = new ResourceTypes(list);
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.BatchInterface});
+ RemoteResource res = new RemoteResource(APP_SERVER_IP, LIGHT_URI, ResourcePolicy.Observable, types, ifaces);
+
+ /* TEST CODE */
+ res.TimeInterval = 1200;
+ Assert.AreEqual(res.TimeInterval, 1200, "Getter value should not be different from what was set");
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("RemoteResource DeviceId property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.DeviceId A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task DeviceId_READ() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + e.Resource.HostAddress);
+ Assert.IsFalse(String.IsNullOrEmpty(e.Resource.DeviceId), "Device id can not be null or empty");
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ Log.Info(TAG, "Start finding resource");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Event that is called when remote resource's state changes")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.StateChanged E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StateChanged_CHECK_EVENT() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+ RemoteResource resource = null;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += async (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress + ", uri: " + e.Resource.UriPath);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.PostAsync(repr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+ }
+ else if (e.Resource.UriPath == DOOR_URI2)
+ {
+ Log.Info(TAG, "Found new resource");
+ resource = e.Resource;
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ bFlag = false;
+
+ Log.Info(TAG, "Start finding resource again for newly postasync resource");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE2);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ bFlag = false;
+ if (resource != null)
+ {
+ resource.StateChanged += (object sender, StateChangedEventArgs e) =>
+ {
+ Log.Info(TAG, "StateChanged callback :" + e.State);
+ bFlag = true;
+ Assert.IsTrue(e.State==ResourceState.LostSignal, "State is not correct");
+ };
+ Log.Info(TAG, "Calling DeleteAsync");
+ RemoteResponse response = await resource.DeleteAsync();
+ Assert.IsTrue(response.Result==ResponseCode.Deleted, "Response result for delete is not deleted");
+ await waitFlag();
+ Assert.IsTrue(bFlag, "Did not receive state changed event");
+ }
+ }
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Registers observe calback on resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.StartObserving E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StartObserving_CHECK_EVENT() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ bFlag = false;
+ ResourceTypes types = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ ifaces.Add(ResourceInterfaces.BatchInterface);
+ ResourcePolicy policy = ResourcePolicy.Discoverable | ResourcePolicy.Observable;
+
+ RemoteResource res = new RemoteResource(hostAddress, DOOR_URI, policy, types, ifaces);
+ res.ObserverNotified += (object sender, ObserverNotifiedEventArgs e) =>
+ {
+ bFlag = true;
+ };
+
+ res.StartObserving(ObservePolicy.AcceptOutOfOrder);
+ await waitFlag();
+ Assert.True(bFlag, "Did not receive observer notified event");
+ /*
+ * POSTCONDITION
+ */
+ res.StopObserving();
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Deregisters observe calback on resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.StopObserving E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task StopObserving_CHECK_EVENT() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ IoTConnectivityClientManager.ResourceFound += (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ bFlag = false;
+ ResourceTypes types = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ ifaces.Add(ResourceInterfaces.BatchInterface);
+ ResourcePolicy policy = ResourcePolicy.Discoverable | ResourcePolicy.Observable;
+
+ RemoteResource res = new RemoteResource(hostAddress, DOOR_URI, policy, types, ifaces);
+ res.ObserverNotified += (object sender, ObserverNotifiedEventArgs e) =>
+ {
+ bFlag = true;
+ };
+
+ res.StartObserving(ObservePolicy.AcceptOutOfOrder);
+ await waitFlag();
+
+ /* TEST CODE */
+ try
+ {
+ if (bFlag)
+ {
+ res.StopObserving();
+ }
+ else
+ Assert.IsTrue(false, "observer notified were never received");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets resource attributes")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.GetAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task GetAsync_CALLBACK() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += async (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ RemoteResponse response = await e.Resource.GetAsync();
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Post request on a resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.PostAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task PostAsync_CALLBACK() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += async (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.PostAsync(repr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+ }
+ else if (e.Resource.UriPath == LIGHT_URI)
+ {
+ Representation lightrepr = new Representation();
+ lightrepr.UriPath = LIGHT_URI;
+ lightrepr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ lightrepr.Attributes = new Attributes()
+ {
+ { LIGHT_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.PostAsync(lightrepr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Puts representation of a resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.PutAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task PutAsync_CALLBACK() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += async (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.PutAsync(repr);
+ Assert.IsTrue(response.Result==ResponseCode.Ok, "Response result is not ok");
+ }
+ else if (e.Resource.UriPath == LIGHT_URI)
+ {
+ Representation lightrepr = new Representation();
+ lightrepr.UriPath = LIGHT_URI;
+ lightrepr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ lightrepr.Attributes = new Attributes()
+ {
+ { LIGHT_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.PutAsync(lightrepr);
+ Assert.IsTrue(response.Result==ResponseCode.Forbidden, "Response result is not forbidden");
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Deletes the resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.RemoteResource.DeleteAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static async Task DeleteAsync_CALLBACK() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityClientManager.Initialize();
+ int id = 0;
+
+ /* TEST CODE */
+ IoTConnectivityClientManager.ResourceFound += async (object sender, ResourceFoundEventArgs e) =>
+ {
+ bFlag = true;
+ hostAddress = e.Resource.HostAddress;
+ Log.Info(TAG, "Found resource at host address :" + hostAddress);
+ if (e.Resource.UriPath == DOOR_URI)
+ {
+ Representation repr = new Representation();
+ repr.UriPath = DOOR_URI;
+ repr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ repr.Attributes = new Attributes()
+ {
+ { DOOR_ATTRIBUTE, 1 }
+ };
+ RemoteResponse response = await e.Resource.DeleteAsync();
+ Assert.IsTrue(response.Result==ResponseCode.Deleted, "Response result is not deleted");
+ }
+ else if (e.Resource.UriPath == LIGHT_URI)
+ {
+ Representation lightrepr = new Representation();
+ lightrepr.UriPath = LIGHT_URI;
+ lightrepr.Type = new ResourceTypes(new List<string>(){RESOURCE_TYPE});
+ lightrepr.Attributes = new Attributes()
+ {
+ { LIGHT_ATTRIBUTE, 1 }
+ };
+ RemoteResponse literesponse = await e.Resource.DeleteAsync();
+ Assert.IsTrue(literesponse.Result==ResponseCode.Forbidden, "Response result is not forbidden");
+ }
+ };
+ IoTConnectivityClientManager.FindingErrorOccurred += (object sender, FindingErrorOccurredEventArgs e) =>
+ {
+ Assert.IsTrue(false, "Can not find remote resource");
+ };
+ if (String.IsNullOrEmpty(hostAddress))
+ {
+ Log.Info(TAG, "Start finding resource to get host address");
+ id = IoTConnectivityClientManager.StartFindingResource(null, RESOURCE_TYPE);
+ await waitFlag();
+ Assert.True(id>=1 , "Invalid request id");
+ Assert.True(bFlag, "Did not receive resource found event");
+ }
+
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityClientManager.Deinitialize();
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.RepresentationT {
+
+ [TestFixture]
+ [Description("Class to test Representation")]
+ public class RepresentationTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "RepresentationTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "RepresentationTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Constructor of Representation")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ try
+ {
+ Representation repr = new Representation();
+ Assert.IsNotNull(repr, "Representation should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("UriPath property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation.UriPath A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void UriPath_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Representation repr = new Representation();
+
+ /* TEST CODE */
+ try
+ {
+ repr.UriPath = "/a/light";
+ var uri = repr.UriPath;
+ Assert.AreEqual(uri, "/a/light", "Getter value should not be different from what was set");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Type property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation.Type A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Type_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Representation repr = new Representation();
+ ResourceTypes types = new ResourceTypes(new List<string>(){"org.tizen.light"});
+
+ /* TEST CODE */
+ try
+ {
+ repr.Type = types;
+ var type = repr.Type;
+ int index = 0;
+ foreach(string item in type)
+ {
+ if (index == 0)
+ Assert.AreEqual(item, "org.tizen.light", "Getter value should not be different from what was set");
+ index++;
+ }
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Interface property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation.Interface A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Interface_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Representation repr = new Representation();
+ ResourceInterfaces ifaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+
+ /* TEST CODE */
+ try
+ {
+ repr.Interface = ifaces;
+ var iface = repr.Interface;
+ int index = 0;
+ foreach(string item in iface)
+ {
+ if (index == 0)
+ Assert.AreEqual(item, "oic.if.baseline", "Value is incorrect");
+ index++;
+ }
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Attributes property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation.Attributes A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Attributes_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Representation repr = new Representation();
+ Attributes attributes = new Attributes()
+ {
+ {"state", "ON"},
+ {"dim", 10}
+ };
+
+ /* TEST CODE */
+ try
+ {
+ repr.Attributes = attributes;
+ var newAttributes = repr.Attributes;
+ string strval = newAttributes["state"] as string;
+ Assert.AreEqual(strval, "ON", "Value is incorrect");
+ int intval = (int)newAttributes["dim"];
+ Assert.AreEqual(intval, 10, "Value is incorrect");
+
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Children property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Representation.Children A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Children_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Representation repr = new Representation();
+
+ Representation child1 = new Representation();
+ ResourceTypes types1 = new ResourceTypes(new List<string>(){"org.tizen.light"});
+ child1.Type = types1;
+ ResourceInterfaces ifaces1 = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ child1.Interface = ifaces1;
+
+ Representation child2 = new Representation();
+ ResourceTypes types2 = new ResourceTypes(new List<string>(){"org.tizen.door"});
+ child2.Type = types2;
+ ResourceInterfaces ifaces2 = new ResourceInterfaces(new List<string>(){ResourceInterfaces.LinkInterface});
+ child2.Interface = ifaces2;
+
+ /* TEST CODE */
+ try
+ {
+ repr.Children.Add(child1);
+ repr.Children.Add(child2);
+ Assert.AreEqual(repr.Children.Count, 2, "Count is incorrect");
+ Assert.AreEqual(repr.Children.ElementAt(0), child1, "Something went wrong with 1st child");
+ Assert.AreEqual(repr.Children.ElementAt(1), child2, "Something went wrong with 2nd child");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResourceFoundEventArgsT {
+
+ [TestFixture]
+ [Description("Class to test ResourceFoundEventArgs class")]
+ public class ResourceFoundEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResourceFoundEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResourceFoundEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of ResourceFoundEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.ResourceFoundEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceFoundEventArgs_INIT() {
+ var resourceFoundEventArgs = new ResourceFoundEventArgs();
+ Assert.IsInstanceOf<ResourceFoundEventArgs>(resourceFoundEventArgs);
+ Assert.IsNotNull(resourceFoundEventArgs, "ResourceFoundEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResourceInterfacesT {
+
+ [TestFixture]
+ [Description("Class to test Resource interfaces")]
+ public class ResourceInterfacesTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResourceInterfacesTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResourceInterfacesTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceInterfaces constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceInterfaces_INIT() {
+ try
+ {
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ Assert.IsNotNull(resourceInterfaces, "ResourceInterfaces should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceInterfaces constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceInterfaces_INIT_OVERLOAD() {
+ try
+ {
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>()
+ { ResourceInterfaces.LinkInterface, ResourceInterfaces.ReadonlyInterface }
+ );
+ Assert.IsNotNull(resourceInterfaces, "ResourceInterfaces should not be null after calling constructor.");
+ Assert.AreEqual(resourceInterfaces.Count, 2, "ResourceInterfaces was not constructed properly");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceInterfaces count property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces.Count A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Count_ELEMENTS_COUNT() {
+ /*
+ * PRECONDITION
+ */
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>()
+ { ResourceInterfaces.LinkInterface, ResourceInterfaces.ReadonlyInterface }
+ );
+ /* TEST CODE */
+ var count = resourceInterfaces.Count;
+ Assert.AreEqual(count, 2, "Count is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds resourceInterfaces items")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Add_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>(){ResourceInterfaces.DefaultInterface});
+ /* TEST CODE */
+ try
+ {
+ resourceInterfaces.Add(ResourceInterfaces.BatchInterface);
+ int index = 0;
+ foreach(string item in resourceInterfaces)
+ {
+ if (index == 0)
+ Assert.AreEqual(item, "oic.if.baseline", "Value is incorrect");
+ else
+ Assert.AreEqual(item, "oic.if.b", "Value is incorrect");
+ index++;
+ }
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes resourceInterfaces")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Remove_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>()
+ { ResourceInterfaces.LinkInterface, ResourceInterfaces.ReadonlyInterface }
+ );
+ /* TEST CODE */
+ try
+ {
+ int countBefore = resourceInterfaces.Count;
+ resourceInterfaces.Remove("oic.if.ll");
+ int countAfter = resourceInterfaces.Count;
+ Assert.AreNotEqual(countBefore, countAfter, "Count can not be same as before");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the enumerator to resource types")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceInterfaces.GetEnumerator M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void GetEnumerator_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceInterfaces resourceInterfaces = new ResourceInterfaces(new List<string>()
+ { ResourceInterfaces.LinkInterface, ResourceInterfaces.ReadonlyInterface }
+ );
+ /* TEST CODE */
+ int index = 0;
+ foreach(string item in resourceInterfaces)
+ {
+ if (index == 0)
+ {
+ Assert.AreEqual(item, "oic.if.ll", "Value is incorrect");
+ }
+ else if (index == 1)
+ {
+ Assert.AreEqual(item, "oic.if.r", "Value is incorrect");
+ }
+ index++;
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResourceOptionsT {
+
+ [TestFixture]
+ [Description("Class to test Resource options")]
+ public class ResourceOptionsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResourceOptionsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResourceOptionsTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceOptions constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceOptions_INIT() {
+ try
+ {
+ ResourceOptions options = new ResourceOptions();
+ Assert.IsNotNull(options, "Options should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resource option keys properties")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Keys A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Keys_LIST_OF_KEYS() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ options.Add(2055, "sample value");
+ /* TEST CODE */
+ var keys = options.Keys;
+ Assert.AreEqual(keys.Count, 2, "No of keys is incorrect");
+ Assert.AreEqual(keys.ElementAt(0), 2050, "Key mismatch");
+ Assert.AreEqual(keys.ElementAt(1), 2055, "Key mismatch");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resource option values properties")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Values A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Values_LIST_OF_VALUES() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ options.Add(2055, "sample value");
+ /* TEST CODE */
+ var values = options.Values;
+ Assert.AreEqual(values.Count, 2, "No of values is incorrect");
+ Assert.AreEqual(values.ElementAt(0), "12345", "Value mismatch");
+ Assert.AreEqual(values.ElementAt(1), "sample value", "Value mismatch");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resource option count property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Count A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Count_ELEMENTS_COUNT() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ options.Add(2055, "sample value");
+ /* TEST CODE */
+ var count = options.Count;
+ Assert.AreEqual(count, 2, "Count is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resource option isReadOnly property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.IsReadOnly A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void IsReadOnly_PROPERTY_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ options.Add(2055, "sample value");
+ /* TEST CODE */
+ Assert.IsFalse(options.IsReadOnly, "Incorrect IsReadOnly property value");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resource option indexer property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Indexer A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void INDEXER_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ /* TEST CODE */
+ Assert.AreEqual(options[2050], "12345", "Value is incorrect");
+ options[2055] = "sample";
+ Assert.AreEqual(options[2055], "sample", "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks if the given key exists")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.ContainsKey M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ContainsKey_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ /* TEST CODE */
+ try
+ {
+ Assert.IsTrue(options.ContainsKey(2050), "Key should be present");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds option key and value")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Add_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ /* TEST CODE */
+ try
+ {
+ options.Add(2050, "12345");
+ Assert.IsTrue(options.ContainsKey(2050), "Key should be present");
+ Assert.AreEqual(options[2050], "12345", "Value is incorrect");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes option")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Remove_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ /* TEST CODE */
+ try
+ {
+ options.Remove(2050);
+ Assert.IsFalse(options.ContainsKey(2050), "Key should not be present");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets option value")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.TryGetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void TryGetValue_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ /* TEST CODE */
+ string value;
+ var isPresent = options.TryGetValue(2050, out value);
+ Assert.IsTrue(isPresent, "Key should be present");
+ Assert.AreEqual(value, "12345", "Value is incorrect");
+ }
+
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds option key and value as key value pair")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void AddPair_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ /* TEST CODE */
+ options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
+ Assert.IsTrue(options.ContainsKey(2050), "Key should be present");
+ Assert.AreEqual(options[2050], "12345", "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Clears all options")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Clear M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Clear_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(2050, "12345");
+ options.Add(2055, "sample");
+ /* TEST CODE */
+ options.Clear();
+ Assert.AreEqual(options.Count, 0, "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks if the key value pair exists")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Contains M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Contains_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
+ /* TEST CODE */
+ var isPresent = options.Contains(new KeyValuePair<ushort, string>(2050, "12345"));
+ Assert.IsTrue(isPresent, "Key value pair should be there");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Copies elements")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.CopyTo M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void CopyTo_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
+ /* TEST CODE */
+ KeyValuePair<ushort, string>[] dest = new KeyValuePair<ushort, string>[options.Count];
+ int index = 0;
+ options.CopyTo(dest, index);
+ Assert.AreEqual(dest[0].Key, 2050, "Copied key is incorrect");
+ Assert.AreEqual(dest[0].Value, "12345", "Copied value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes key value pair")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void RemovePair_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
+ /* TEST CODE */
+ options.Remove(new KeyValuePair<ushort, string>(2050, "12345"));
+ var isPresent = options.Contains(new KeyValuePair<ushort, string>(2050, "12345"));
+ Assert.IsFalse(isPresent, "Key value pair should not be present");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the enumerator to options")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceOptions.GetEnumerator M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void GetEnumerator_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceOptions options = new ResourceOptions();
+ options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
+ options.Add(new KeyValuePair<ushort, string>(2055, "sample"));
+ /* TEST CODE */
+ int index = 0;
+ foreach(KeyValuePair<ushort, string> pair in options)
+ {
+ if (index == 0)
+ {
+ Assert.AreEqual(pair.Key, 2050, "Key is incorrect");
+ Assert.AreEqual(pair.Value, "12345", "Value is incorrect");
+ }
+ else if (index == 1)
+ {
+ Assert.AreEqual(pair.Key, 2055, "Key is incorrect");
+ Assert.AreEqual(pair.Value, "sample", "Value is incorrect");
+ }
+ index++;
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResourceQueryT {
+
+ [TestFixture]
+ [Description("Class to test Resource Query")]
+ public class ResourceQueryTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResourceQueryTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResourceQueryTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceQuery_INIT() {
+ try
+ {
+ ResourceQuery query = new ResourceQuery();
+ Assert.IsNotNull(query, "ResourceQuery should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Type property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Type A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Type_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+
+ /* TEST CODE */
+ query.Type = "org.tizen.light";
+ var type = query.Type;
+ Assert.AreEqual(type, "org.tizen.light", "Getter value should not be different from what was set");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Interface property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Interface A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Interface_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+
+ /* TEST CODE */
+ query.Interface = ResourceInterfaces.LinkInterface;
+ Assert.AreEqual(query.Interface, "oic.if.ll", "Getter value should not be different from what was set");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery keys properties")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Keys A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Keys_LIST_OF_KEYS() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("newKey", "sample value");
+ /* TEST CODE */
+ var keys = query.Keys;
+ Assert.AreEqual(keys.Count, 2, "No of keys is incorrect");
+ Assert.AreEqual(keys.ElementAt(0), "key", "Key mismatch");
+ Assert.AreEqual(keys.ElementAt(1), "newKey", "Key mismatch");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery values properties")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Values A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Values_LIST_OF_VALUES() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("newKey", "sample value");
+ /* TEST CODE */
+ var values = query.Values;
+ Assert.AreEqual(values.Count, 2, "No of values is incorrect");
+ Assert.AreEqual(values.ElementAt(0), "value", "Value mismatch");
+ Assert.AreEqual(values.ElementAt(1), "sample value", "Value mismatch");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery count property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Count A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Count_ELEMENTS_COUNT() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("newKey", "sample value");
+ /* TEST CODE */
+ var count = query.Count;
+ Assert.AreEqual(count, 2, "Count is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery isReadOnly property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.IsReadOnly A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void IsReadOnly_PROPERTY_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("newKey", "sample value");
+ /* TEST CODE */
+ Assert.IsFalse(query.IsReadOnly, "Incorrect IsReadOnly property value");
+ }
+
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceQuery indexer property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Indexer A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void INDEXER_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ /* TEST CODE */
+ Assert.AreEqual(query["key"], "value", "Value is incorrect");
+ query["key1"] = "value1";
+ Assert.AreEqual(query["key1"], "value1", "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks if the given key exists")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.ContainsKey M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ContainsKey_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ /* TEST CODE */
+ try
+ {
+ Assert.IsTrue(query.ContainsKey("key"), "Key should be present");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds query key and value")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Add_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ /* TEST CODE */
+ try
+ {
+ query.Add("key", "value");
+ Assert.IsTrue(query.ContainsKey("key"), "Key should be present");
+ Assert.AreEqual(query["key"], "value", "Value is incorrect");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes query")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Remove_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ /* TEST CODE */
+ try
+ {
+ query.Remove("key");
+ Assert.IsFalse(query.ContainsKey("key"), "Key should not be present");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets query value")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.TryGetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void TryGetValue_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ /* TEST CODE */
+ string value;
+ var isPresent = query.TryGetValue("key", out value);
+ Assert.IsTrue(isPresent, "Key should be present");
+ Assert.AreEqual(value, "value", "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds query key and value as key value pair")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void AddPair_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ /* TEST CODE */
+ query.Add(new KeyValuePair<string, string>("key", "value"));
+ Assert.IsTrue(query.ContainsKey("key"), "Key should be present");
+ Assert.AreEqual(query["key"], "value", "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Clears all querys")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Clear M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Clear_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("key1", "value1");
+ /* TEST CODE */
+ query.Clear();
+ Assert.AreEqual(query.Count, 0, "Value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks if the key value pair exists")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Contains M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Contains_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("key1", "value1");
+ /* TEST CODE */
+ var isPresent = query.Contains(new KeyValuePair<string, string>("key", "value"));
+ Assert.IsTrue(isPresent, "Key value pair should be there");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Copies query elements")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.CopyTo M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void CopyTo_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("key1", "value1");
+ /* TEST CODE */
+ KeyValuePair<string, string>[] dest = new KeyValuePair<string, string>[query.Count];
+ int index = 0;
+ query.CopyTo(dest, index);
+ Assert.AreEqual(dest[0].Key, "key", "Copied key is incorrect");
+ Assert.AreEqual(dest[0].Value, "value", "Copied value is incorrect");
+ Assert.AreEqual(dest[1].Key, "key1", "Copied key is incorrect");
+ Assert.AreEqual(dest[1].Value, "value1", "Copied value is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes key value pair")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void RemovePair_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("key1", "value1");
+ /* TEST CODE */
+ query.Remove(new KeyValuePair<string, string>("key1", "value1"));
+ var isPresent = query.Contains(new KeyValuePair<string, string>("key1", "value1"));
+ Assert.IsFalse(isPresent, "Key value pair should not be present");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the enumerator to querys")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceQuery.GetEnumerator M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void GetEnumerator_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceQuery query = new ResourceQuery();
+ query.Add("key", "value");
+ query.Add("key1", "value1");
+ /* TEST CODE */
+ int index = 0;
+ foreach(KeyValuePair<string, string> pair in query)
+ {
+ if (index == 0)
+ {
+ Assert.AreEqual(pair.Key, "key", "Key is incorrect");
+ Assert.AreEqual(pair.Value, "value", "Value is incorrect");
+ }
+ else if (index == 1)
+ {
+ Assert.AreEqual(pair.Key, "key1", "Key is incorrect");
+ Assert.AreEqual(pair.Value, "value1", "Value is incorrect");
+ }
+ index++;
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResourceTypesT {
+
+ [TestFixture]
+ [Description("Class to test Resource types")]
+ public class ResourceTypesTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResourceTypesTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResourceTypesTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceTypes constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceTypes_INIT() {
+ try
+ {
+ List<string> list = new List<string>()
+ {
+ "org.tizen.door"
+ };
+ ResourceTypes resourceTypes = new ResourceTypes(list);
+ Assert.IsNotNull(resourceTypes, "ResourceTypes should not be null after calling constructor.");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceTypes constructor")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void ResourceTypes_INIT_OVERLOAD() {
+ try
+ {
+ ResourceTypes resourceTypes = new ResourceTypes(new List<string>() { "org.tizen.light", "oic.if.room" });
+ Assert.IsNotNull(resourceTypes, "ResourceTypes should not be null after calling constructor.");
+ Assert.AreEqual(resourceTypes.Count, 2, "ResourceTypes was not constructed properly");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("ResourceTypes count property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes.Count A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Count_ELEMENTS_COUNT() {
+ /*
+ * PRECONDITION
+ */
+ ResourceTypes resourceTypes = new ResourceTypes(new List<string>() { "org.tizen.light", "oic.if.room" });
+ /* TEST CODE */
+ var count = resourceTypes.Count;
+ Assert.AreEqual(count, 2, "Count is incorrect");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Adds resourceTypes items")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes.Add M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Add_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ List<string> list = new List<string>()
+ {
+ "org.tizen.door"
+ };
+ ResourceTypes resourceTypes = new ResourceTypes(list);
+ /* TEST CODE */
+ try
+ {
+ resourceTypes.Add("org.tizen.light");
+ int index = 0;
+ foreach(string item in resourceTypes)
+ {
+ if (index == 0)
+ Assert.AreEqual(item, "org.tizen.door", "Value is incorrect");
+ else
+ Assert.AreEqual(item, "org.tizen.light", "Value is incorrect");
+ index++;
+ }
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Removes resourceTypes")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes.Remove M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Remove_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceTypes resourceTypes = new ResourceTypes(new List<string>() { "org.tizen.light", "oic.if.room" });
+ /* TEST CODE */
+ try
+ {
+ int countBefore = resourceTypes.Count;
+ resourceTypes.Remove("oic.if.room");
+ int countAfter = resourceTypes.Count;
+ Assert.AreNotEqual(countBefore, countAfter, "Count can not be same as before");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the enumerator to resource types")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.ResourceTypes.GetEnumerator M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void GetEnumerator_RETURN_VALUE() {
+ /*
+ * PRECONDITION
+ */
+ ResourceTypes resourceTypes = new ResourceTypes(new List<string>() { "org.tizen.light", "oic.if.room" });
+ /* TEST CODE */
+ int index = 0;
+ foreach(string item in resourceTypes)
+ {
+ if (index == 0)
+ {
+ Assert.AreEqual(item, "org.tizen.light", "Value is incorrect");
+ }
+ else if (index == 1)
+ {
+ Assert.AreEqual(item, "oic.if.room", "Value is incorrect");
+ }
+ index++;
+ }
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.ResponseT {
+
+ [TestFixture]
+ [Description("Class to test Response APIs")]
+ public class ResponseTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ResponseTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ResponseTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Constructor of Response")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Response M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ var response = new Response();
+ Assert.IsInstanceOf<Response>(response);
+ Assert.IsNotNull(response, "Response should be not null after init.");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Result property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Response.Result A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Result_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Response response = new Response();
+
+ /* TEST CODE */
+ response.Result = ResponseCode.Deleted;
+ if (response.Result == ResponseCode.Deleted)
+ Assert.Pass();
+ else
+ Assert.True(false, "Getter value should not be different from what was set");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Representation property")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.Response.Representation A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Representation_READ_WRITE() {
+ /*
+ * PRECONDITION
+ */
+ Response response = new Response();
+ Representation repr = new Representation();
+ ResourceTypes types = new ResourceTypes(new List<string>(){"org.tizen.light"});
+ repr.Type = types;
+ repr.UriPath = "/a/light";
+
+ /* TEST CODE */
+ response.Representation = repr;
+ Assert.AreEqual(response.Representation, repr, "Getter value should not be different from what was set");
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Runtime.CompilerServices;
+using System.Diagnostics;
+using TestFramework;
+using Tizen;
+using Tizen.Applications;
+using Tizen.UI;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.IoTServerManagerT {
+
+ [TestFixture]
+ [Description("Test class to test server manager")]
+ public class ServerManagerTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "ServerManagerTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "ServerManagerTest Destroy : " + i++);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Initialize IOT Server Manager")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.Initialize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Initialize_INIT() {
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.Initialize();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityServerManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Denitialize IOT Server Manager")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.Deinitialize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void Deinitialize_CHANGE_STATUS() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityServerManager.Deinitialize();
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.Deinitialize();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Registers a resource")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.RegisterResource M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void RegisterResource_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityServerManager.Initialize();
+ ResourceTypes types = new ResourceTypes(new List<string>(){"org.tizen.light"});
+ Attributes attributes = new Attributes {
+ {"state", "ON"}
+ };
+ Resource res = new LiteResource("/room/1", types, ResourcePolicy.Discoverable, attributes);
+
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.RegisterResource(res);
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityServerManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Starts presence of a server")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.StartSendingPresence M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void StartSendingPresence_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityServerManager.Initialize();
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.StartSendingPresence(120);
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityServerManager.StopSendingPresence();
+ IoTConnectivityServerManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Stops presence of a server")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.StopSendingPresence M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void StopSendingPresence_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityServerManager.Initialize();
+ IoTConnectivityServerManager.StartSendingPresence(120);
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.StopSendingPresence();
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityServerManager.Deinitialize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets device name")]
+ [Property("SPEC", " Tizen.NetWork.IoTConnectivity.IoTConnectivityServerManager.SetDeviceName M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void SetDeviceName_USAGE() {
+ /*
+ * PRECONDITION
+ */
+ IoTConnectivityServerManager.Initialize();
+ /* TEST CODE */
+ try
+ {
+ IoTConnectivityServerManager.SetDeviceName("mydevice");
+ }
+ catch(Exception ex)
+ {
+ Assert.IsTrue(false, "Exception caught : " + ex.Message);
+ }
+ Assert.True(true);
+ /*
+ * POSTCONDITION
+ */
+ IoTConnectivityServerManager.Deinitialize();
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Threading;
+using System.Linq;
+using System.Collections.Generic;
+using TestFramework;
+using Tizen;
+using Tizen.Network.IoTConnectivity;
+
+namespace TizenTest.StateChangedEventArgsT {
+
+ [TestFixture]
+ [Description("Test class to test StateChangedEventArgs class")]
+ public class StateChangedEventArgsTest {
+ private static string TAG = "IOT-TEST";
+ private static int i = 1;
+
+ [SetUp]
+ public static void Init() {
+ Log.Info(TAG, "StateChangedEventArgsTest Init :" + i);
+ }
+
+ [TearDown]
+ public static void Destroy() {
+ Log.Info(TAG, "StateChangedEventArgsTest Destroy : " + i++);
+ }
+
+ [Test]//pass
+ [Category("P1")]
+ [Description("Constructor of StateChangedEventArgs")]
+ [Property("SPEC", "Tizen.NetWork.IoTConnectivity.StateChangedEventArgs C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
+ public static void StateChangedEventArgs_INIT() {
+ var stateChangedEventArgs = new StateChangedEventArgs();
+ Assert.IsInstanceOf<StateChangedEventArgs>(stateChangedEventArgs);
+ Assert.IsNotNull(stateChangedEventArgs, "StateChangedEventArgs should be not null after init.");
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.test.iotconnectivity.tizen" version="1.0.0">
+ <ui-application appid="org.test.iotconnectivity.tizen" exec="tct-iotconnectivity-tizen-tests" type="capp" multiple="false" taskmanage="true" nodisplay="false">
+ <icon>icon.png</icon>
+ <label>tct-iotconnectivity-tizen-tests</label>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ <privilege>http://tizen.org/privilege/internet</privilege>
+ </privileges>
+</manifest>