19 lines
622 B
C#
19 lines
622 B
C#
using System.Collections.Concurrent;
|
|
using System.Text.Json;
|
|
using backend.Tools;
|
|
|
|
namespace backend.tests;
|
|
|
|
// Slim version for Tasks 9-15. Task 16 reopens this file to add IDeviceClient + envelope sending.
|
|
public class FakeDeviceChannel : IDeviceChannel
|
|
{
|
|
public ConcurrentQueue<JsonElement> PiToolReplies { get; } = new();
|
|
|
|
public Task<JsonElement> CallPiToolAsync(string name, JsonElement args, CancellationToken ct)
|
|
{
|
|
if (PiToolReplies.TryDequeue(out var reply))
|
|
return Task.FromResult(reply);
|
|
return Task.FromResult(JsonDocument.Parse("""{"ok":true}""").RootElement);
|
|
}
|
|
}
|