using AxiOmron.PcbCheck.Options; using AxiOmron.PcbCheck.Services.Implementations; using IoTClient.Enums; using Xunit; namespace AxiOmron.PcbCheck.Tests; /// /// 验证欧姆龙 FINS PLC 服务的通信参数解析行为。 /// public sealed class OmronFinsPlcServiceTests { /// /// 默认字节序应使用 ABCD,避免 UInt16 结果代码发生高低字节交换。 /// [Fact] public void ResolveEndianFormat_ShouldUseAbcd_WhenConfigurationIsDefault() { var options = new PlcOptions(); EndianFormat result = OmronFinsPlcService.ResolveEndianFormat(options); Assert.Equal(EndianFormat.ABCD, result); } /// /// 非法字节序配置应抛出明确异常,避免使用错误端序静默读写 PLC 寄存器。 /// [Fact] public void ResolveEndianFormat_ShouldThrow_WhenConfigurationIsInvalid() { var options = new PlcOptions { EndianFormat = "XYZ" }; var exception = Assert.Throws(() => OmronFinsPlcService.ResolveEndianFormat(options)); Assert.Contains("PLC 字节序配置无效", exception.Message); } }