using Shouldly;
using Xunit;
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests;
///
/// OpcUaServer-002 — unit coverage for , the pure
/// helper that maps a HistoryRead-Events NumValuesPerNode request cap onto the
/// IHistorianDataSource.ReadEventsAsync maxEvents argument. Per OPC UA Part 4/11,
/// NumValuesPerNode == 0 means "no limit — return ALL values", so the helper translates 0 to
/// UNBOUNDED () rather than the backend's maxEvents <= 0
/// "use the default cap" sentinel; a positive value passes through clamped to .
///
public sealed class NodeManagerEventMaxEventsTests
{
/// 0 ("no limit" per the spec) ⇒ int.MaxValue (unbounded), NOT the 0/default-cap sentinel.
[Fact]
public void Zero_maps_to_int_max()
{
OtOpcUaNodeManager.EventMaxEvents(0u).ShouldBe(int.MaxValue);
}
/// A normal positive cap passes through unchanged.
[Fact]
public void Normal_value_passes_through()
{
OtOpcUaNodeManager.EventMaxEvents(50u).ShouldBe(50);
OtOpcUaNodeManager.EventMaxEvents(1u).ShouldBe(1);
}
/// A value above int.MaxValue clamps to int.MaxValue (mirrors ClampToInt's saturation).
[Fact]
public void Value_above_int_max_clamps()
{
OtOpcUaNodeManager.EventMaxEvents((uint)int.MaxValue + 1u).ShouldBe(int.MaxValue);
OtOpcUaNodeManager.EventMaxEvents(uint.MaxValue).ShouldBe(int.MaxValue);
}
/// int.MaxValue exactly passes through (boundary — not clamped down).
[Fact]
public void Int_max_exactly_passes_through()
{
OtOpcUaNodeManager.EventMaxEvents((uint)int.MaxValue).ShouldBe(int.MaxValue);
}
}