2022-08-30 15:42:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using TINK.Services.BluetoothLock.BLE;
|
|
|
|
|
|
|
|
|
|
namespace TestLockItBLE.Services.BluetoothLock.BLE
|
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestPluginBleHelper
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestGetDeviceState()
|
|
|
|
|
{
|
|
|
|
|
foreach (Plugin.BLE.Abstractions.DeviceState state in Enum.GetValues(typeof(Plugin.BLE.Abstractions.DeviceState)))
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case Plugin.BLE.Abstractions.DeviceState.Connecting:
|
|
|
|
|
Assert.That(state.GetDeviceState(),
|
|
|
|
|
Is.EqualTo(TINK.Services.BluetoothLock.DeviceState.Connecting));
|
|
|
|
|
break;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
case Plugin.BLE.Abstractions.DeviceState.Connected:
|
|
|
|
|
Assert.That(state.GetDeviceState(),
|
|
|
|
|
Is.EqualTo(TINK.Services.BluetoothLock.DeviceState.Connected));
|
|
|
|
|
break;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
case Plugin.BLE.Abstractions.DeviceState.Disconnected:
|
|
|
|
|
Assert.That(state.GetDeviceState(),
|
|
|
|
|
Is.EqualTo(TINK.Services.BluetoothLock.DeviceState.Disconnected));
|
|
|
|
|
break;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
case Plugin.BLE.Abstractions.DeviceState.Limited:
|
|
|
|
|
Assert.That(state.GetDeviceState(),
|
|
|
|
|
Is.EqualTo(TINK.Services.BluetoothLock.DeviceState.Limited));
|
|
|
|
|
break;
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
default:
|
|
|
|
|
throw new Exception($"Unexpected state {state} detected.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-30 15:42:25 +02:00
|
|
|
|
}
|