using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Driver.Modbus.Cli.Commands;

namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus.Cli.Tests;

[Trait("Category", "Unit")]
public sealed class ReadCommandTests
{
    /// <summary>Verifies that SynthesiseTagName produces a stable, readable tag name format.</summary>
    /// <param name="region">The Modbus region.</param>
    /// <param name="address">The register address.</param>
    /// <param name="type">The Modbus data type.</param>
    /// <param name="expected">The expected synthesised tag name string.</param>
    [Theory]
    [InlineData(ModbusRegion.HoldingRegisters, 100, ModbusDataType.UInt16, "HR[100]:UInt16")]
    [InlineData(ModbusRegion.Coils, 0, ModbusDataType.Bool, "Coil[0]:Bool")]
    [InlineData(ModbusRegion.DiscreteInputs, 42, ModbusDataType.Bool, "DI[42]:Bool")]
    [InlineData(ModbusRegion.InputRegisters, 5, ModbusDataType.Int16, "IR[5]:Int16")]
    [InlineData(ModbusRegion.HoldingRegisters, 200, ModbusDataType.Float32, "HR[200]:Float32")]
    public void SynthesiseTagName_produces_stable_region_prefix_plus_address_plus_type(
        ModbusRegion region, ushort address, ModbusDataType type, string expected)
    {
        ReadCommand.SynthesiseTagName(region, address, type).ShouldBe(expected);
    }
}
