chore: organize solution into module folders (Core/Server/Drivers/Client/Tooling)
Group all 69 projects into category subfolders under src/ and tests/ so the Rider Solution Explorer mirrors the module structure. Folders: Core, Server, Drivers (with a nested Driver CLIs subfolder), Client, Tooling. - Move every project folder on disk with git mv (history preserved as renames). - Recompute relative paths in 57 .csproj files: cross-category ProjectReferences, the lib/ HintPath+None refs in Driver.Historian.Wonderware, and the external mxaccessgw refs in Driver.Galaxy and its test project. - Rebuild ZB.MOM.WW.OtOpcUa.slnx with nested solution folders. - Re-prefix project paths in functional scripts (e2e, compliance, smoke SQL, integration, install). Build green (0 errors); unit tests pass. Docs left for a separate pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Cli.Commands;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Cli.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Covers <see cref="WriteCommand.ParseValue"/> for the IEC 61131-3 atomic types
|
||||
/// TwinCAT exposes. Wider matrix than AB CIP because IEC adds WSTRING + the four
|
||||
/// TIME/DATE variants that all marshal as UDINT on the wire.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class WriteCommandParseValueTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("true", true)]
|
||||
[InlineData("0", false)]
|
||||
[InlineData("on", true)]
|
||||
[InlineData("NO", false)]
|
||||
public void ParseValue_Bool_accepts_common_aliases(string raw, bool expected)
|
||||
{
|
||||
WriteCommand.ParseValue(raw, TwinCATDataType.Bool).ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_Bool_rejects_garbage()
|
||||
{
|
||||
Should.Throw<CliFx.Exceptions.CommandException>(
|
||||
() => WriteCommand.ParseValue("maybe", TwinCATDataType.Bool));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_SInt_signed_byte()
|
||||
{
|
||||
WriteCommand.ParseValue("-128", TwinCATDataType.SInt).ShouldBe((sbyte)-128);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_USInt_unsigned_byte()
|
||||
{
|
||||
WriteCommand.ParseValue("255", TwinCATDataType.USInt).ShouldBe((byte)255);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_Int_signed_16bit()
|
||||
{
|
||||
WriteCommand.ParseValue("-32768", TwinCATDataType.Int).ShouldBe((short)-32768);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_UInt_unsigned_16bit()
|
||||
{
|
||||
WriteCommand.ParseValue("65535", TwinCATDataType.UInt).ShouldBe((ushort)65535);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_DInt_int32_bounds()
|
||||
{
|
||||
WriteCommand.ParseValue("-2147483648", TwinCATDataType.DInt).ShouldBe(int.MinValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_UDInt_uint32_max()
|
||||
{
|
||||
WriteCommand.ParseValue("4294967295", TwinCATDataType.UDInt).ShouldBe(uint.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_LInt_int64_min()
|
||||
{
|
||||
WriteCommand.ParseValue("-9223372036854775808", TwinCATDataType.LInt).ShouldBe(long.MinValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_ULInt_uint64_max()
|
||||
{
|
||||
WriteCommand.ParseValue("18446744073709551615", TwinCATDataType.ULInt).ShouldBe(ulong.MaxValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_Real_invariant_culture()
|
||||
{
|
||||
WriteCommand.ParseValue("3.14", TwinCATDataType.Real).ShouldBe(3.14f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_LReal_higher_precision()
|
||||
{
|
||||
WriteCommand.ParseValue("2.718281828", TwinCATDataType.LReal).ShouldBeOfType<double>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_String_passthrough()
|
||||
{
|
||||
WriteCommand.ParseValue("hallo beckhoff", TwinCATDataType.String).ShouldBe("hallo beckhoff");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_WString_passthrough()
|
||||
{
|
||||
// CLI layer doesn't distinguish UTF-8 input; the driver handles the WSTRING
|
||||
// encoding on the wire.
|
||||
WriteCommand.ParseValue("überstall", TwinCATDataType.WString).ShouldBe("überstall");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(TwinCATDataType.Time)]
|
||||
[InlineData(TwinCATDataType.Date)]
|
||||
[InlineData(TwinCATDataType.DateTime)]
|
||||
[InlineData(TwinCATDataType.TimeOfDay)]
|
||||
public void ParseValue_IEC_date_time_variants_land_on_uint32(TwinCATDataType type)
|
||||
{
|
||||
// IEC 61131-3 TIME / DATE / DT / TOD all marshal as UDINT on the wire; the CLI
|
||||
// accepts a numeric raw value and lets the caller handle the encoding.
|
||||
WriteCommand.ParseValue("1234567", type).ShouldBeOfType<uint>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_Structure_refused()
|
||||
{
|
||||
Should.Throw<CliFx.Exceptions.CommandException>(
|
||||
() => WriteCommand.ParseValue("42", TwinCATDataType.Structure));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseValue_non_numeric_for_numeric_types_throws()
|
||||
{
|
||||
Should.Throw<FormatException>(
|
||||
() => WriteCommand.ParseValue("xyz", TwinCATDataType.DInt));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MAIN.bStart", TwinCATDataType.Bool, "MAIN.bStart:Bool")]
|
||||
[InlineData("GVL.Counter", TwinCATDataType.DInt, "GVL.Counter:DInt")]
|
||||
[InlineData("Motor1.Status.Running", TwinCATDataType.Bool, "Motor1.Status.Running:Bool")]
|
||||
[InlineData("Recipe[3]", TwinCATDataType.Real, "Recipe[3]:Real")]
|
||||
public void SynthesiseTagName_preserves_symbolic_path_verbatim(
|
||||
string symbol, TwinCATDataType type, string expected)
|
||||
{
|
||||
ReadCommand.SynthesiseTagName(symbol, type).ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user