[Non-ACR][Bluetooth][Add Bluetooth OPP Server TCs] 43/197143/3
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 10 Jan 2019 02:03:00 +0000 (11:03 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 11 Jan 2019 03:57:11 +0000 (12:57 +0900)
Change-Id: I9a50ffef17673309d5a5289a44131e2e5e2d01a3
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothOppServer.cs [new file with mode: 0644]

diff --git a/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothOppServer.cs b/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothOppServer.cs
new file mode 100644 (file)
index 0000000..f61cd92
--- /dev/null
@@ -0,0 +1,176 @@
+using BluetoothNetworkUtils;
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Tizen.System;
+
+namespace Tizen.Network.Bluetooth.Tests
+{
+    [TestFixture]
+    [Description("BluetoothOppServer Tests")]
+    public class BluetoothOppServerTests
+    {
+        BluetoothOppServer _oppServer = null;
+        string filePath = StorageManager.Storages.Where(s => s.StorageType == StorageArea.Internal).FirstOrDefault().RootDirectory + "/Downloads";
+        bool isBluetoothOppSupported = false;
+
+        [SetUp]
+        public void Init()
+        {
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
+            Information.TryGetValue("tizen.org/feature/network.bluetooth.opp", out isBluetoothOppSupported);
+        }
+        [TearDown]
+        public void Destroy()
+        {
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Create a BluetoothOppServer Object")]
+        [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.BluetoothOppServer C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")]
+        public void BluetoothOppServer_INIT()
+        {
+            try
+            {
+                var bluetoothOppServer = new BluetoothOppServer();
+
+                Assert.IsInstanceOf<BluetoothOppServer>(bluetoothOppServer, "Should return BluetoothOppServer instance.");
+                Assert.IsNotNull(bluetoothOppServer, "BluetoothOppServer instance should not be null");
+            }
+            catch (Exception ex)
+            {
+                if (ex is NotSupportedException)
+                {
+                    Assert.IsTrue(isBluetoothOppSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.Fail("Throwing exception " + ex.ToString());
+                }
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test StartServer, check if StartServer method works properly")]
+        [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.StartServer M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")]
+        public void StartServer_CHECK_START_SERVER()
+        {
+            try
+            {
+                _oppServer = BluetoothOppServer.StartServer(filePath);
+
+                Assert.IsInstanceOf<BluetoothOppServer>(_oppServer, "Should return BluetoothOppServer instance.");
+                Assert.IsNotNull(_oppServer, "BluetoothOppServer instance should not be null");
+
+                _oppServer.StopServer();
+            }
+            catch (Exception ex)
+            {
+                if (ex is NotSupportedException)
+                {
+                    Assert.IsTrue(isBluetoothOppSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.Fail("Throwing exception " + ex.ToString());
+                }
+            }
+            finally
+            {
+                if (_oppServer != null)
+                {
+                    _oppServer = null;
+                }
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test StopServer, check if StopServer method works properly")]
+        [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.StopServer M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")]
+        public void StopServer_CHECK_STOP_SERVER()
+        {
+            try
+            {
+                _oppServer = BluetoothOppServer.StartServer(filePath);
+
+                Assert.IsInstanceOf<BluetoothOppServer>(_oppServer, "Should return BluetoothOppServer instance.");
+                Assert.IsNotNull(_oppServer, "BluetoothOppServer instance should not be null");
+
+                _oppServer.StopServer();
+            }
+            catch (Exception ex)
+            {
+                if (ex is NotSupportedException)
+                {
+                    Assert.IsTrue(isBluetoothOppSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.Fail("Throwing exception " + ex.ToString());
+                }
+            }
+            finally
+            {
+                if (_oppServer != null)
+                {
+                    _oppServer = null;
+                }
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test SetDestinationPath, check if SetDestinationPath method works properly")]
+        [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.SetDestinationPath M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")]
+        public void SetDestinationPath_CHECK_SET_DESTINATION()
+        {
+            try
+            {
+                _oppServer = BluetoothOppServer.StartServer(filePath);
+
+                Assert.IsInstanceOf<BluetoothOppServer>(_oppServer, "Should return BluetoothOppServer instance.");
+                Assert.IsNotNull(_oppServer, "BluetoothOppServer instance should not be null");
+
+                _oppServer.SetDestinationPath(filePath);
+
+                _oppServer.StopServer();
+            }
+            catch (Exception ex)
+            {
+                if (ex is NotSupportedException)
+                {
+                    Assert.IsTrue(isBluetoothOppSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.Fail("Throwing exception " + ex.ToString());
+                }
+            }
+            finally
+            {
+                if (_oppServer != null)
+                {
+                    _oppServer = null;
+                }
+            }
+        }
+    }
+}