Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Raw/FakeRawTreeService.cs
T

140 lines
7.3 KiB
C#

using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Raw;
/// <summary>
/// Minimal <see cref="IRawTreeService"/> fake for component-class tests (AdminUI has no bUnit, so the
/// raw modals are exercised as plain classes with this injected). Only the raw modals' open-path
/// members — <see cref="LoadTagForEditAsync"/> and <see cref="LoadMergedProbeConfigAsync"/> — are
/// configurable, via the two settable delegates; every other member throws, so an unexpected call
/// fails the test instead of passing vacuously. The two delegates themselves default to throwing for
/// the same reason: a test must opt in to the calls it expects.
/// </summary>
internal sealed class FakeRawTreeService : IRawTreeService
{
/// <summary>The <see cref="LoadTagForEditAsync"/> stand-in; throws until a test sets it.</summary>
public Func<string, RawTagEditDto?> OnLoadTagForEdit { get; set; } =
_ => throw new NotImplementedException();
/// <summary>The <see cref="LoadMergedProbeConfigAsync"/> stand-in; throws until a test sets it.</summary>
public Func<string, (string DriverType, string MergedConfigJson)?> OnLoadMergedProbeConfig { get; set; } =
_ => throw new NotImplementedException();
/// <summary>
/// Optional asynchronous override of <see cref="OnLoadTagForEdit"/>. The sync delegates above
/// complete inline, which cannot express two opens overlapping on one modal instance — set this to
/// gate a load on a <see cref="TaskCompletionSource"/> and interleave the second open.
/// </summary>
public Func<string, Task<RawTagEditDto?>>? OnLoadTagForEditAsync { get; set; }
/// <summary>Optional asynchronous override of <see cref="OnLoadMergedProbeConfig"/>; see <see cref="OnLoadTagForEditAsync"/>.</summary>
public Func<string, Task<(string DriverType, string MergedConfigJson)?>>? OnLoadMergedProbeConfigAsync { get; set; }
/// <inheritdoc/>
public Task<RawTagEditDto?> LoadTagForEditAsync(string tagId, CancellationToken ct = default)
=> OnLoadTagForEditAsync is { } async ? async(tagId) : Task.FromResult(OnLoadTagForEdit(tagId));
/// <inheritdoc/>
public Task<(string DriverType, string MergedConfigJson)?> LoadMergedProbeConfigAsync(
string deviceId, CancellationToken ct = default)
=> OnLoadMergedProbeConfigAsync is { } async
? async(deviceId)
: Task.FromResult(OnLoadMergedProbeConfig(deviceId));
/// <inheritdoc/>
public Task<IReadOnlyList<RawNode>> LoadRootsAsync(CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<IReadOnlyList<RawNode>> LoadChildrenAsync(RawNode parent, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> CreateFolderAsync(string clusterId, string? parentFolderId, string name, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawRenameResult> RenameFolderAsync(string rawFolderId, string newName, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> DeleteFolderAsync(string rawFolderId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> MoveDriverToFolderAsync(string driverInstanceId, string? targetFolderId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> CreateDriverAsync(string clusterId, string? folderId, string name, string driverType, string driverConfigJson, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawRenameResult> RenameDriverAsync(string driverInstanceId, string newName, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> SetDriverEnabledAsync(string driverInstanceId, bool enabled, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> DeleteDriverAsync(string driverInstanceId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> CreateDeviceAsync(string driverInstanceId, string name, string deviceConfigJson, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawRenameResult> RenameDeviceAsync(string deviceId, string newName, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> DeleteDeviceAsync(string deviceId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> CreateTagGroupAsync(string deviceId, string? parentGroupId, string name, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawRenameResult> RenameTagGroupAsync(string tagGroupId, string newName, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> DeleteTagGroupAsync(string tagGroupId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> DeleteTagAsync(string tagId, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> CreateTagAsync(string deviceId, string? tagGroupId, RawTagInput input, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> UpdateTagAsync(string tagId, RawTagInput input, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawTagImportResult> ImportTagsAsync(string deviceId, IReadOnlyList<RawTagImportRow> rows, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawDriverEditDto?> LoadDriverForEditAsync(string driverInstanceId, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> UpdateDriverAsync(string driverInstanceId, string name, string driverConfigJson, string? resilienceConfig, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<RawDeviceEditDto?> LoadDeviceForEditAsync(string deviceId, CancellationToken ct = default)
=> throw new NotImplementedException();
/// <inheritdoc/>
public Task<UnsMutationResult> UpdateDeviceAsync(string deviceId, string name, string deviceConfigJson, bool enabled, byte[] rowVersion, CancellationToken ct = default)
=> throw new NotImplementedException();
}