30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using FinlyticEngine.Services.Mqtt;
|
|
|
|
namespace FinlyticEngine.Tests.TestSupport;
|
|
|
|
/// <summary>
|
|
/// Fake for <see cref="IEngineRpcClient"/>. Records every published MQTT event so tests can assert on
|
|
/// fire-and-forget notifications without a real broker (Rules.md §13: isolated, non-destructive tests only).
|
|
/// </summary>
|
|
public class FakeEngineRpcClient : IEngineRpcClient
|
|
{
|
|
public List<(string Topic, object? Data)> PublishedMessages { get; } = new();
|
|
|
|
/// <inheritdoc />
|
|
public Task<TResponse?> SendRpcRequestAsync<TResponse, TRequest>(string channel, TRequest requestData, TimeSpan? timeout = null)
|
|
where TResponse : class
|
|
where TRequest : class
|
|
=> throw new InvalidOperationException(
|
|
"SendRpcRequestAsync is only used by EvaluateAssetAsync, which is out of scope for the tenant-boundary tests in this suite.");
|
|
|
|
/// <inheritdoc />
|
|
public Task PublishAsync<T>(string topic, T data, bool retain = false)
|
|
{
|
|
PublishedMessages.Add((topic, data));
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|