64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
67 lines
2.9 KiB
C#
67 lines
2.9 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Modbus.Cli.Commands;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus.Cli.Tests;
|
|
|
|
/// <summary>
|
|
/// Covers <see cref="ProbeCommand.ComputeVerdict"/> — the headline-string helper that
|
|
/// combines the driver-side <see cref="DriverState"/> with the probe snapshot's OPC UA
|
|
/// <see cref="DataValueSnapshot.StatusCode"/> so the operator never sees the previous
|
|
/// contradictory pair (`Health: Healthy` above a `Status: Bad...` snapshot line — see
|
|
/// Driver.Modbus.Cli-006).
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class ProbeCommandTests
|
|
{
|
|
/// <summary>Verifies that ComputeVerdict returns OK when driver state is Healthy and status is Good.</summary>
|
|
[Fact]
|
|
public void ComputeVerdict_returns_OK_when_state_is_Healthy_and_status_is_Good()
|
|
{
|
|
var verdict = ProbeCommand.ComputeVerdict(DriverState.Healthy, statusCode: 0x00000000u);
|
|
|
|
verdict.ShouldContain("OK");
|
|
}
|
|
|
|
/// <summary>Verifies that ComputeVerdict returns FAIL when driver state is not Healthy.</summary>
|
|
/// <param name="state">The driver state to test.</param>
|
|
[Theory]
|
|
[InlineData(DriverState.Faulted)]
|
|
[InlineData(DriverState.Reconnecting)]
|
|
[InlineData(DriverState.Unknown)]
|
|
public void ComputeVerdict_returns_FAIL_when_driver_state_is_not_Healthy(DriverState state)
|
|
{
|
|
var verdict = ProbeCommand.ComputeVerdict(state, statusCode: 0x00000000u);
|
|
|
|
verdict.ShouldContain("FAIL");
|
|
}
|
|
|
|
/// <summary>Verifies that ComputeVerdict returns FAIL when snapshot status is Bad even if driver is Healthy.</summary>
|
|
/// <param name="statusCode">The OPC UA status code to test.</param>
|
|
[Theory]
|
|
[InlineData(0x80050000u)] // BadCommunicationError
|
|
[InlineData(0x800A0000u)] // BadTimeout
|
|
[InlineData(0x80740000u)] // BadTypeMismatch
|
|
[InlineData(0x80000000u)] // generic Bad
|
|
public void ComputeVerdict_returns_FAIL_when_snapshot_status_is_Bad_even_if_driver_state_Healthy(uint statusCode)
|
|
{
|
|
// Driver.Modbus.Cli-006: a successful InitializeAsync sets DriverState.Healthy, but
|
|
// the FC03 probe read may still fail (snapshot.StatusCode != Good). Previously the
|
|
// headline reported Healthy while the snapshot line below showed Bad. The verdict
|
|
// must reflect the actual probe-read outcome.
|
|
var verdict = ProbeCommand.ComputeVerdict(DriverState.Healthy, statusCode);
|
|
|
|
verdict.ShouldContain("FAIL");
|
|
}
|
|
|
|
/// <summary>Verifies that ComputeVerdict returns DEGRADED for uncertain status with healthy driver.</summary>
|
|
[Fact]
|
|
public void ComputeVerdict_returns_DEGRADED_for_uncertain_status_with_healthy_driver()
|
|
{
|
|
var verdict = ProbeCommand.ComputeVerdict(DriverState.Healthy, statusCode: 0x40000000u);
|
|
|
|
verdict.ShouldContain("DEGRADED");
|
|
}
|
|
}
|