sharee.bike-App/TestFramework/Services/BluetoothLock/LocksServiceMock.cs

87 lines
3.2 KiB
C#
Raw Normal View History

2023-04-19 12:14:14 +02:00
using System;
2021-07-12 21:31:46 +02:00
using System.Collections.Generic;
using System.Threading.Tasks;
2022-08-30 15:42:25 +02:00
using TINK.Model.Bikes;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
2021-07-12 21:31:46 +02:00
using TINK.Services.BluetoothLock;
using TINK.Services.BluetoothLock.Tdo;
2021-11-14 23:27:29 +01:00
namespace TestFramework.Services.BluetoothLock
2021-07-12 21:31:46 +02:00
{
2022-09-06 16:08:19 +02:00
public class LocksServiceMock : ILocksService
{
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
public async Task<IEnumerable<LockInfoTdo>> GetLocksStateAsync(IEnumerable<LockInfoAuthTdo> locksInfo, TimeSpan connectTimeout)
{
return await Task.FromResult(new List<LockInfoTdo>());
}
2021-07-12 21:31:46 +02:00
2023-04-19 12:14:14 +02:00
/// <summary> Holds timeout values for series of connecting attempts to a lock or multiple locks. </summary>
2022-09-06 16:08:19 +02:00
public ITimeOutProvider TimeOut { get; set; }
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
public void UpdateSimulation(BikeCollection bikes) { }
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Opens lock.</summary>
/// <param name="bike">Bike object to update.</param>
public async Task<LockitLockingState?> OpenAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Open);
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Closes lock.</summary>
/// <param name="bike">Bike object to update.</param>
public async Task<LockitLockingState?> CloseAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Closed);
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Gets the state of a bike. </summary>
/// <param name="lockId">Id of lockId to get state for.</param>
/// <returns></returns>
public async Task<LockitLockingState?> GetState(string lockId) => await Task.FromResult((LockitLockingState?)null);
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Connects to lock.</summary>
/// <param name="authInfo"> Info required to connect to lock.</param>
/// <param name="connectTimeout">Timeout for connect operation.</param>
public async Task<LockInfoTdo> ConnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout)
{
return await Task.FromResult(new LockInfoTdo.Builder { Id = 12, Guid = new System.Guid("00000000-0000-0000-0000-000000000042"), State = null }.Build());
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Set sound settings.</summary>
/// <param name="lockId">Id of lock to set sound settings.</param>
public async Task<bool> SetSoundAsync(int lockId, SoundSettings settings)
{
return await Task.FromResult(true);
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Gets battery percentage.</summary>
/// <param name="lockId">Id of lock to get info for.</param>
public Task<double> GetBatteryPercentageAsync(int lockId)
{
throw new NotSupportedException();
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Sets whether alarm is on or off.</summary>
/// <param name="lockId">Id of lock to get info from.</param>
public async Task SetIsAlarmOffAsync(int lockId, bool activated)
{
await Task.FromResult(true);
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Gets whether alarm is on or off.</summary>
/// <param name="lockId">Id of lock to get info for.</param>
public async Task<bool> GetIsAlarmOffAsync(int lockId)
{
return await Task.FromResult(true);
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>Gets a lock by bike Id.</summary>
/// <param name="bikeId"></param>
/// <returns>Lock object</returns>
public ILockService this[int bikeId]
{
get
{
return null;
}
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
public Task<LockingState> DisconnectAsync(int bikeId, Guid bikeGuid) => throw new NotSupportedException();
}
2021-07-12 21:31:46 +02:00
}