--- /dev/null
+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;
+ }
+ }
+ }
+ }
+}