mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 13:57:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -11,190 +11,190 @@ using TINK.Services.BluetoothLock.Tdo;
|
|||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Settings.BluetoothLock
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestLockIt
|
||||
{
|
||||
[Test]
|
||||
public void TestAuthenticate_InvalidSeed()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var ciper = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
[TestFixture]
|
||||
public class TestLockIt
|
||||
{
|
||||
[Test]
|
||||
public void TestAuthenticate_InvalidSeed()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var ciper = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
|
||||
Assert.That(() => LockItEventBased.Authenticate(device, authInfo, adapter, ciper), Throws.InstanceOf<AuthKeyException>());
|
||||
}
|
||||
Assert.That(() => LockItEventBased.Authenticate(device, authInfo, adapter, ciper), Throws.InstanceOf<AuthKeyException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAuthenticate_InvalidAuthKey()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var ciper = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
[Test]
|
||||
public void TestAuthenticate_InvalidAuthKey()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var ciper = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'t', (byte)'q', (byte)'2', (byte)'n', (byte)'c', (byte)'A', (byte)'I', (byte)'v', (byte)'M', (byte)'t', (byte)'h', (byte)'g', (byte)'x', (byte)'a', (byte)'z', (byte)'B' },
|
||||
K_u = new byte[] { }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'t', (byte)'q', (byte)'2', (byte)'n', (byte)'c', (byte)'A', (byte)'I', (byte)'v', (byte)'M', (byte)'t', (byte)'h', (byte)'g', (byte)'x', (byte)'a', (byte)'z', (byte)'B' },
|
||||
K_u = new byte[] { }
|
||||
}.Build();
|
||||
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
|
||||
Assert.That(async () => { await LockItEventBased.Authenticate(device, authInfo, adapter, ciper); }, Throws.InstanceOf<AuthKeyException>());
|
||||
}
|
||||
Assert.That(async () => { await LockItEventBased.Authenticate(device, authInfo, adapter, ciper); }, Throws.InstanceOf<AuthKeyException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAuthenticate_Invalidated()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
var activateLock = Substitute.For<ICharacteristic>();
|
||||
[Test]
|
||||
public void TestAuthenticate_Invalidated()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
var activateLock = Substitute.For<ICharacteristic>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'z', (byte)'D', (byte)'G', (byte)'x', (byte)'q', (byte)'M', (byte)'f', (byte)'A', (byte)'F', (byte)'q', (byte)'g', (byte)'N', (byte)'V', (byte)'r', (byte)'N', (byte)'Y' },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'z', (byte)'D', (byte)'G', (byte)'x', (byte)'q', (byte)'M', (byte)'f', (byte)'A', (byte)'F', (byte)'q', (byte)'g', (byte)'N', (byte)'V', (byte)'r', (byte)'N', (byte)'Y' },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
|
||||
// Call authenticate to invalidate seed
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
// Call authenticate to invalidate seed
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
|
||||
// Authenticate again to
|
||||
var execption = Assert.Throws<AggregateException>(() => { var dummy = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result; });
|
||||
// Authenticate again to
|
||||
var execption = Assert.Throws<AggregateException>(() => { var dummy = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result; });
|
||||
|
||||
Assert.That(
|
||||
execption.InnerExceptions[0].Message,
|
||||
Does.Contain("Seed 122,68,71,120,113,77,102,65,70,113,103,78,86,114,78,89 was already used."));
|
||||
Assert.That(
|
||||
execption.InnerExceptions[0].Message,
|
||||
Does.Contain("Seed 122,68,71,120,113,77,102,65,70,113,103,78,86,114,78,89 was already used."));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAuthenticate_GetAuthCharacteristicThrowsException()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
var activateLock = Substitute.For<ICharacteristic>();
|
||||
[Test]
|
||||
public void TestAuthenticate_GetAuthCharacteristicThrowsException()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
var activateLock = Substitute.For<ICharacteristic>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult((ICharacteristic)null));
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult((ICharacteristic)null));
|
||||
|
||||
// Authenticate again to
|
||||
Assert.That(() => LockItEventBased.Authenticate(device, authInfo, adapter, cipher), Throws.InstanceOf<CoundntGetCharacteristicException>());
|
||||
}
|
||||
// Authenticate again to
|
||||
Assert.That(() => LockItEventBased.Authenticate(device, authInfo, adapter, cipher), Throws.InstanceOf<CoundntGetCharacteristicException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestAuthenticate_GetLockState_Closed()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
[Test]
|
||||
public async Task TestAuthenticate_GetLockState_Closed()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
var state = Substitute.For<ICharacteristic>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
// Calls related to get lock state.
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
// Calls related to get lock state.
|
||||
|
||||
// Call authenticate to invalidate seed
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baaa-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(state));
|
||||
state.ReadAsync(Arg.Any<CancellationToken>()).Returns(new byte[] { 1 });
|
||||
// Call authenticate to invalidate seed
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baaa-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(state));
|
||||
state.ReadAsync(Arg.Any<CancellationToken>()).Returns(new byte[] { 1 });
|
||||
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
|
||||
Assert.That((await lockIt.GetLockStateAsync()).State, Is.EqualTo(LockitLockingState.Closed));
|
||||
}
|
||||
Assert.That((await lockIt.GetLockStateAsync()).State, Is.EqualTo(LockitLockingState.Closed));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAuthenticate_GetLockState_GetStateCharacteristicThrowsException()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
[Test]
|
||||
public void TestAuthenticate_GetLockState_GetStateCharacteristicThrowsException()
|
||||
{
|
||||
var device = Substitute.For<IDevice>();
|
||||
var adapter = Substitute.For<IAdapter>();
|
||||
var cipher = Substitute.For<TINK.Model.Device.ICipher>();
|
||||
var auth = Substitute.For<ICharacteristic>();
|
||||
var lockControl = Substitute.For<IService>();
|
||||
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'y', (byte)'D', (byte)'G', (byte)'x', (byte)'q', (byte)'M', (byte)'f', (byte)'A', (byte)'F', (byte)'q', (byte)'g', (byte)'N', (byte)'V', (byte)'r', (byte)'N', (byte)'Y' },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
var authInfo = new LockInfoAuthTdo.Builder
|
||||
{
|
||||
K_seed = new byte[] { (byte)'y', (byte)'D', (byte)'G', (byte)'x', (byte)'q', (byte)'M', (byte)'f', (byte)'A', (byte)'F', (byte)'q', (byte)'g', (byte)'N', (byte)'V', (byte)'r', (byte)'N', (byte)'Y' },
|
||||
K_u = new byte[] { 1 }
|
||||
}.Build();
|
||||
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
// Calls related to Authenticate functionality.
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("0000f00d-1212-efde-1523-785fef13d123"));
|
||||
device.GetServiceAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>()).Returns(Task.FromResult(lockControl));
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baab-1212-efde-1523-785fef13d123")).Returns(Task.FromResult(auth));
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(Task.FromResult(true));
|
||||
auth.ReadAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult(new byte[8]));
|
||||
cipher.Decrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[3]);
|
||||
cipher.Encrypt(Arg.Any<byte[]>(), Arg.Any<byte[]>()).Returns(new byte[16]);
|
||||
auth.WriteAsync(Arg.Any<byte[]>()).Returns(true);
|
||||
device.State.Returns(DeviceState.Connected);
|
||||
device.Id.Returns(new Guid("00000000-0000-0000-0000-000000000001"));
|
||||
|
||||
// Calls related to get lock state.
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baaa-1212-efde-1523-785fef13d123")).Returns(Task.FromResult((ICharacteristic)null));
|
||||
// Calls related to get lock state.
|
||||
lockControl.GetCharacteristicAsync(new Guid("0000baaa-1212-efde-1523-785fef13d123")).Returns(Task.FromResult((ICharacteristic)null));
|
||||
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
var lockIt = LockItEventBased.Authenticate(device, authInfo, adapter, cipher).Result;
|
||||
|
||||
Assert.That(async () => (await lockIt.GetLockStateAsync()).State, Throws.InstanceOf<CoundntGetCharacteristicException>());
|
||||
}
|
||||
}
|
||||
Assert.That(async () => (await lockIt.GetLockStateAsync()).State, Throws.InstanceOf<CoundntGetCharacteristicException>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@ using TINK.ViewModel.Settings;
|
|||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Settings
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestGroupFilterSettings
|
||||
{
|
||||
[Test]
|
||||
public void TestDoFilter()
|
||||
{
|
||||
var l_oFilter = new GroupFilterSettings(new Dictionary<string, FilterState> { { $"HOM_{FilterHelper.CITYBIKE}", FilterState.Off }, { $"HOM_{FilterHelper.CARGOBIKE}", FilterState.On }, { "HOM_117025", FilterState.On } });
|
||||
[TestFixture]
|
||||
public class TestGroupFilterSettings
|
||||
{
|
||||
[Test]
|
||||
public void TestDoFilter()
|
||||
{
|
||||
var l_oFilter = new GroupFilterSettings(new Dictionary<string, FilterState> { { $"HOM_{FilterHelper.CITYBIKE}", FilterState.Off }, { $"HOM_{FilterHelper.CARGOBIKE}", FilterState.On }, { "HOM_117025", FilterState.On } });
|
||||
|
||||
var l_oResult = l_oFilter.DoFilter(new List<string> { $"HOM_{FilterHelper.CITYBIKE}", $"HOM_{FilterHelper.CARGOBIKE}" });
|
||||
var l_oResult = l_oFilter.DoFilter(new List<string> { $"HOM_{FilterHelper.CITYBIKE}", $"HOM_{FilterHelper.CARGOBIKE}" });
|
||||
|
||||
Assert.AreEqual(1, l_oResult.ToList().Count);
|
||||
Assert.AreEqual($"HOM_{FilterHelper.CARGOBIKE}", l_oResult.ToList()[0]);
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(1, l_oResult.ToList().Count);
|
||||
Assert.AreEqual($"HOM_{FilterHelper.CARGOBIKE}", l_oResult.ToList()[0]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,38 +4,38 @@ using TINK.Settings;
|
|||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Settings
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestPollingParameters
|
||||
{
|
||||
[Test]
|
||||
public void TestConstruct()
|
||||
{
|
||||
Assert.IsTrue(new PollingParameters(new TimeSpan(0, 0, 11), true).IsActivated);
|
||||
Assert.AreEqual(11, (new PollingParameters(new TimeSpan(0, 0, 11), true).Periode.TotalSeconds));
|
||||
}
|
||||
[TestFixture]
|
||||
public class TestPollingParameters
|
||||
{
|
||||
[Test]
|
||||
public void TestConstruct()
|
||||
{
|
||||
Assert.IsTrue(new PollingParameters(new TimeSpan(0, 0, 11), true).IsActivated);
|
||||
Assert.AreEqual(11, (new PollingParameters(new TimeSpan(0, 0, 11), true).Periode.TotalSeconds));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEquals()
|
||||
{
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 11), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 11), false)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 12), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
}
|
||||
[Test]
|
||||
public void TestEquals()
|
||||
{
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 11), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 11), false)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 12), true)) == (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnequals()
|
||||
{
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 11), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 11), false)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 12), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
}
|
||||
[Test]
|
||||
public void TestUnequals()
|
||||
{
|
||||
Assert.IsFalse((new PollingParameters(new TimeSpan(0, 0, 11), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 11), false)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
Assert.IsTrue((new PollingParameters(new TimeSpan(0, 0, 12), true)) != (new PollingParameters(new TimeSpan(0, 0, 11), true)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestToString()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"Polling is on=True, polling interval=11[sec].",
|
||||
(new PollingParameters(new TimeSpan(0, 0, 11), true).ToString()));
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
public void TestToString()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"Polling is on=True, polling interval=11[sec].",
|
||||
(new PollingParameters(new TimeSpan(0, 0, 11), true).ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,38 +8,38 @@ using TINK.ViewModel.Settings;
|
|||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Settings
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSettings
|
||||
{
|
||||
[Test]
|
||||
public void TestConstructDefaults()
|
||||
{
|
||||
var settings = new TINK.Model.Settings.Settings();
|
||||
[TestFixture]
|
||||
public class TestSettings
|
||||
{
|
||||
[Test]
|
||||
public void TestConstructDefaults()
|
||||
{
|
||||
var settings = new TINK.Model.Settings.Settings();
|
||||
|
||||
Assert.AreEqual(LogEventLevel.Error, settings.MinimumLogEventLevel);
|
||||
Assert.AreEqual(LogEventLevel.Error, settings.MinimumLogEventLevel);
|
||||
|
||||
// Was GroupFilterHelper.GetSettingsFilterDefaults when used in TINK- context.
|
||||
Assert.AreEqual(new GroupFilterSettings(), settings.GroupFilterSettings);
|
||||
// Was GroupFilterHelper.GetSettingsFilterDefaults when used in TINK- context.
|
||||
Assert.AreEqual(new GroupFilterSettings(), settings.GroupFilterSettings);
|
||||
|
||||
// Was GroupFilterHelper.GetMapPageFilterDefaults when used in TINK- context.
|
||||
Assert.AreEqual(new GroupFilterMapPage(), settings.GroupFilterMapPage);
|
||||
// Was GroupFilterHelper.GetMapPageFilterDefaults when used in TINK- context.
|
||||
Assert.AreEqual(new GroupFilterMapPage(), settings.GroupFilterMapPage);
|
||||
|
||||
Assert.AreEqual(new CopriServerUriList().ActiveUri, settings.ActiveUri);
|
||||
Assert.AreEqual(new CopriServerUriList().ActiveUri, settings.ActiveUri);
|
||||
|
||||
Assert.AreEqual(PollingParameters.Default, settings.PollingParameters);
|
||||
Assert.AreEqual(PollingParameters.Default, settings.PollingParameters);
|
||||
|
||||
Assert.IsTrue(
|
||||
settings.CenterMapToCurrentLocation,
|
||||
"Center to map for sharee.bike because bt- locks require location info.");
|
||||
}
|
||||
Assert.IsTrue(
|
||||
settings.CenterMapToCurrentLocation,
|
||||
"Center to map for sharee.bike because bt- locks require location info.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorTink()
|
||||
{
|
||||
var settings = new TINK.Model.Settings.Settings(activeUri: new Uri(CopriServerUriList.TINK_LIVE));
|
||||
Assert.IsFalse(
|
||||
settings.CenterMapToCurrentLocation,
|
||||
"Do not center to current location for TINK.");
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
public void TestCtorTink()
|
||||
{
|
||||
var settings = new TINK.Model.Settings.Settings(activeUri: new Uri(CopriServerUriList.TINK_LIVE));
|
||||
Assert.IsFalse(
|
||||
settings.CenterMapToCurrentLocation,
|
||||
"Do not center to current location for TINK.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue