test(raw): FakeRawTreeService for raw-modal component tests

This commit is contained in:
Joseph Doherty
2026-08-05 03:21:23 -04:00
parent ebcf73f72c
commit e698aee401
@@ -0,0 +1,127 @@
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();
/// <inheritdoc/>
public Task<RawTagEditDto?> LoadTagForEditAsync(string tagId, CancellationToken ct = default)
=> Task.FromResult(OnLoadTagForEdit(tagId));
/// <inheritdoc/>
public Task<(string DriverType, string MergedConfigJson)?> LoadMergedProbeConfigAsync(
string deviceId, CancellationToken ct = default)
=> 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();
}