Add ScriptedRealtimeUpstream + FakeDeviceChannel test doubles
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user