mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-22 23:26:31 +01:00
69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TINK.Services.BluetoothLock;
|
|
using TINK.Services.BluetoothLock.BLE;
|
|
using TINK.Services.BluetoothLock.Tdo;
|
|
|
|
namespace TestLockItBLE.Services.BluetoothLock.BLE
|
|
{
|
|
public class TestLockItServiceBase
|
|
{
|
|
[Test]
|
|
public async Task TestCheckReconnect_EmptyList()
|
|
{
|
|
var disconnectedDevice = Substitute.For<ILockService>();
|
|
disconnectedDevice.GetDeviceState().Returns(DeviceState.Disconnected);
|
|
var devices = new List<ILockService> { disconnectedDevice };
|
|
var locksInfo = new List<LockInfoAuthTdo>();
|
|
|
|
await LockItServiceBase.CheckReconnect(
|
|
devices,
|
|
locksInfo,
|
|
TimeSpan.FromSeconds(0));
|
|
|
|
await disconnectedDevice.DidNotReceive().ReconnectAsync(Arg.Any<LockInfoAuthTdo>(), Arg.Any<TimeSpan>());
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestCheckReconnect_NoMatchingIdEntry()
|
|
{
|
|
var disconnectedDevice = Substitute.For<ILockService>();
|
|
disconnectedDevice.GetDeviceState().Returns(DeviceState.Disconnected);
|
|
disconnectedDevice.Name.Returns("ISHAREIT+334");
|
|
disconnectedDevice.Guid.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
|
|
|
var devices = new List<ILockService> { disconnectedDevice };
|
|
var locksInfo = new List<LockInfoAuthTdo> { new LockInfoAuthTdo.Builder { Id = 992, Guid = new Guid("00000000-0000-0000-0000-000000000002"), K_seed = new byte[] { 2 }, K_u = new byte[] { 3 } }.Build() };
|
|
|
|
await LockItServiceBase.CheckReconnect(
|
|
devices,
|
|
locksInfo,
|
|
TimeSpan.FromSeconds(0));
|
|
|
|
await disconnectedDevice.DidNotReceive().ReconnectAsync(Arg.Any<LockInfoAuthTdo>(), Arg.Any<TimeSpan>());
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestCheckReconnect()
|
|
{
|
|
var disconnectedDevice = Substitute.For<ILockService>();
|
|
disconnectedDevice.GetDeviceState().Returns(DeviceState.Disconnected);
|
|
disconnectedDevice.Name.Returns("ISHAREIT+992");
|
|
disconnectedDevice.Guid.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
|
|
|
var devices = new List<ILockService> { disconnectedDevice };
|
|
var locksInfo = new List<LockInfoAuthTdo> { new LockInfoAuthTdo.Builder { Id = 992, Guid = new Guid("00000000-0000-0000-0000-000000000002"), K_seed = new byte[] { 2 }, K_u = new byte[] { 3 }}.Build() };
|
|
|
|
await LockItServiceBase.CheckReconnect(
|
|
devices,
|
|
locksInfo,
|
|
TimeSpan.FromSeconds(0));
|
|
|
|
await disconnectedDevice.Received().ReconnectAsync(Arg.Any<LockInfoAuthTdo>(), Arg.Any<TimeSpan>());
|
|
}
|
|
}
|
|
}
|