using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TINK.Model.Bike;
using TINK.Model.Bike.BluetoothLock;
using TINK.Services.BluetoothLock.Tdo;
using System;
namespace TINK.Services.BluetoothLock
{
///
/// Facke locks service implementation which simulates locks which are out of reach.
///
public class LocksServiceOutOfReach : ILocksServiceFake
{
private IEnumerable LocksInfo { get; set; } = new List();
/// Holds timeout values for series of connecting attemps to a lock or multiple locks.
public ITimeOutProvider TimeOut { get; set; }
/// Connects to lock.
/// Info required to connect to lock.
/// Timeout for connect operation.
public async Task ConnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout)
{
return await Task.FromResult(new LockInfoTdo.Builder { Id = authInfo.Id, Guid = authInfo.Guid, State = null }.Build());
}
/// No info availalbe because no lock is in reach.
/// Timeout for connect operation of a single lock.
/// Empty collection.
public async Task> GetLocksStateAsync(IEnumerable locksInfo, TimeSpan connectTimeout) => await Task.FromResult(LocksInfo);
/// No changes required because lock state is unknown.
public void UpdateSimulation(BikeCollection bikes)
{
var locksInfo = new List();
// Add and process locks info object
foreach (var bikeInfo in bikes.OfType())
{
locksInfo.Add(new LockInfoTdo.Builder { Id = bikeInfo.LockInfo.Id, State = null }.Build());
}
LocksInfo = locksInfo;
}
/// Gets a lock by bike Id.
///
/// Lock object
public ILockService this[int bikeId]
{
get
{
return null;
}
}
/// Disconnects lock.
/// Id of lock to disconnect.
/// Guid of lock to disconnect.
public async Task DisconnectAsync(int bikeId, Guid bikeGuid) => await Task.FromResult(LockingState.UnknownDisconnected);
}
}