sharee.bike-App/SharedBusinessLogic.Tests.Framework/Services/BluetoothLock/LocksServiceMock.cs

87 lines
3.2 KiB
C#
Raw Permalink 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;
2024-04-09 12:53:23 +02:00
using ShareeBike.Model.Bikes;
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
using ShareeBike.Services.BluetoothLock;
using ShareeBike.Services.BluetoothLock.Tdo;
2021-07-12 21:31:46 +02:00
2024-04-09 12:53:23 +02:00
namespace SharedBusinessLogic.Tests.Framework.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
}