2022-08-30 15:42:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using NUnit.Framework;
|
2024-04-09 12:53:23 +02:00
|
|
|
|
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
|
|
|
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 TestLockInfo
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCtor()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(
|
|
|
|
|
new LockInfo.Builder { Id = 123 }.Build().State, Is.EqualTo(LockingState.UnknownDisconnected));
|
2022-08-30 15:42:25 +02:00
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(
|
|
|
|
|
new LockInfo.Builder { Id = 123 }.Build().Id, Is.EqualTo(123));
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEquals()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.True);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_Id()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 3,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_Guid()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("1000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_Seed()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 5, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_UserKey()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 9, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_AdminKey()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 11, 1 },
|
|
|
|
|
State = LockingState.Closed
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestEqualsFalse_LockingState()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
Assert.That(new LockInfo.Builder
|
2022-09-06 16:08:19 +02:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Closed
|
|
|
|
|
}.Build() == new LockInfo.Builder
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
|
|
|
|
Seed = new byte[] { 1, 2 },
|
|
|
|
|
UserKey = new byte[] { 7, 2 },
|
|
|
|
|
AdminKey = new byte[] { 2, 1 },
|
|
|
|
|
State = LockingState.Open
|
2024-04-09 12:53:23 +02:00
|
|
|
|
}.Build(), Is.False);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-13 20:09:46 +02:00
|
|
|
|
}
|