116 lines
3.7 KiB
C#
116 lines
3.7 KiB
C#
using ZB.MOM.WW.MxGateway.Worker.Conversion;
|
|
using ZB.MOM.WW.MxGateway.Worker.MxAccess;
|
|
|
|
namespace ZB.MOM.WW.MxGateway.Worker.Tests.TestSupport;
|
|
|
|
/// <summary>
|
|
/// Shared no-operation <see cref="IMxAccessServer"/> for tests that need to
|
|
/// construct an <see cref="MxAccessSession"/> via
|
|
/// <see cref="MxAccessSession.CreateForTesting"/> but do not exercise any
|
|
/// MXAccess COM call. Replaces the per-file <c>NullMxAccessServer</c> copy
|
|
/// that previously lived inside <c>AlarmCommandExecutorTests</c> and was
|
|
/// constructed via reflection — see Worker.Tests-016 for the rationale.
|
|
/// </summary>
|
|
internal sealed class NoopMxAccessServer : IMxAccessServer
|
|
{
|
|
/// <inheritdoc />
|
|
public int Register(string clientName) => 0;
|
|
|
|
/// <inheritdoc />
|
|
public void Unregister(int serverHandle)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public int AddItem(int serverHandle, string itemDefinition) => 0;
|
|
|
|
/// <inheritdoc />
|
|
public int AddItem2(int serverHandle, string itemDefinition, string itemContext) => 0;
|
|
|
|
/// <inheritdoc />
|
|
public void RemoveItem(int serverHandle, int itemHandle)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Advise(int serverHandle, int itemHandle)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void UnAdvise(int serverHandle, int itemHandle)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void AdviseSupervisory(int serverHandle, int itemHandle)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public int AddBufferedItem(int serverHandle, string itemDefinition, string itemContext) => 0;
|
|
|
|
/// <inheritdoc />
|
|
public void SetBufferedUpdateInterval(int serverHandle, int updateIntervalMilliseconds)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public object Suspend(int serverHandle, int itemHandle) => new FakeMxStatus();
|
|
|
|
/// <inheritdoc />
|
|
public object Activate(int serverHandle, int itemHandle) => new FakeMxStatus();
|
|
|
|
/// <inheritdoc />
|
|
public void Write(int serverHandle, int itemHandle, object? value, int userId)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Write2(int serverHandle, int itemHandle, object? value, object? timestampValue, int userId)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void WriteSecured(int serverHandle, int itemHandle, int currentUserId, int verifierUserId, object? value)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void WriteSecured2(int serverHandle, int itemHandle, int currentUserId, int verifierUserId, object? value, object? timestampValue)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public int AuthenticateUser(int serverHandle, string verifyUser, string verifyUserPassword) => 0;
|
|
|
|
/// <inheritdoc />
|
|
public int ArchestrAUserToId(int serverHandle, string userIdGuid) => 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Minimal stand-in for the native <c>ArchestrA.MxAccess.MxStatus</c> struct.
|
|
/// <see cref="MxStatusProxyConverter"/> reflects over the public
|
|
/// <c>success</c>, <c>category</c>, <c>detectedBy</c>, and <c>detail</c>
|
|
/// fields, so this fake exposes the same field shape with all-OK values.
|
|
/// </summary>
|
|
internal sealed class FakeMxStatus
|
|
{
|
|
// These public fields exist solely so MxStatusProxyConverter can reflect
|
|
// over them by name; they are read through reflection, not directly, so the
|
|
// compiler's "never assigned" (CS0649) diagnostic does not apply.
|
|
#pragma warning disable CS0649
|
|
/// <summary>Success indicator field read by the status converter.</summary>
|
|
public int success;
|
|
|
|
/// <summary>Status category field read by the status converter.</summary>
|
|
public int category;
|
|
|
|
/// <summary>Status detected-by field read by the status converter.</summary>
|
|
public int detectedBy;
|
|
|
|
/// <summary>Status detail field read by the status converter.</summary>
|
|
public int detail;
|
|
#pragma warning restore CS0649
|
|
}
|