2024-04-09 12:53:23 +02:00
|
|
|
using System;
|
2021-05-13 20:09:46 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2022-08-30 15:42:25 +02:00
|
|
|
using NUnit.Framework;
|
2024-04-09 12:53:23 +02:00
|
|
|
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
|
|
using ShareeBike.Services.BluetoothLock.Tdo;
|
2021-05-13 20:09:46 +02:00
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.Bike.BluetoothLock
|
2021-05-13 20:09:46 +02:00
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
[TestFixture]
|
|
|
|
public class TestLockInfoHelper
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestUpdateById_State()
|
|
|
|
{
|
|
|
|
var locksInfo = new List<LockInfo> {
|
|
|
|
new LockInfo.Builder { Id = 12, Seed = new byte[] { 3, 5 }, UserKey = new byte[] {2, 1 }, State = LockingState.UnknownFromHardwareError }.Build(),
|
|
|
|
new LockInfo.Builder { Id = 14, Seed = new byte[] { 3, 1 }, UserKey = new byte[] {2, 7 }, State = LockingState.Open }.Build(),
|
|
|
|
new LockInfo.Builder { Id = 3, Seed = new byte[] { 1, 5 }, UserKey = new byte[] {2, 9 }, State = LockingState.Closed }.Build(),
|
|
|
|
};
|
|
|
|
|
|
|
|
var locksInfoTdo = new List<LockInfoTdo> {
|
|
|
|
new LockInfoTdo.Builder { Id =14, State = LockitLockingState.Closed}.Build()
|
|
|
|
};
|
|
|
|
|
|
|
|
var resultList = locksInfo.UpdateById(locksInfoTdo);
|
|
|
|
|
|
|
|
var result = resultList.FirstOrDefault(x => x.Id == 14);
|
2024-04-09 12:53:23 +02:00
|
|
|
Assert.That(result, Is.Not.Null, "Target element was removed.");
|
|
|
|
Assert.That(result.State, Is.EqualTo(LockingState.Closed));
|
2022-09-06 16:08:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestUpdateById_Guid()
|
|
|
|
{
|
|
|
|
var locksInfo = new List<LockInfo> {
|
|
|
|
new LockInfo.Builder { Id = 12, Seed = new byte[] { 3, 5 }, UserKey = new byte[] {2, 1 }, State = LockingState.UnknownFromHardwareError }.Build(),
|
|
|
|
new LockInfo.Builder { Id = 14, Seed = new byte[] { 3, 1 }, UserKey = new byte[] {2, 7 }, State = LockingState.Open }.Build(),
|
|
|
|
new LockInfo.Builder { Id = 3, Seed = new byte[] { 1, 5 }, UserKey = new byte[] {2, 9 }, State = LockingState.Closed }.Build(),
|
|
|
|
};
|
|
|
|
|
|
|
|
var locksInfoTdo = new List<LockInfoTdo> {
|
|
|
|
new LockInfoTdo.Builder { Id =14, Guid = new System.Guid("00000000-0000-0000-0000-e57e6b9aee16"), State = LockitLockingState.Open}.Build()
|
|
|
|
};
|
|
|
|
|
|
|
|
var resultList = locksInfo.UpdateById(locksInfoTdo);
|
|
|
|
|
|
|
|
var result = resultList.FirstOrDefault(x => x.Id == 14);
|
2024-04-09 12:53:23 +02:00
|
|
|
Assert.That(result, Is.Not.Null, "Target element was removed.");
|
|
|
|
Assert.That(result.Guid, Is.EqualTo(new Guid("00000000-0000-0000-0000-e57e6b9aee16")));
|
2022-09-06 16:08:19 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
}
|