using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Client.CLI.Helpers;
namespace ZB.MOM.WW.OtOpcUa.Client.CLI.Tests;
/// Array-valued nodes print their elements, not the CLR type name (#615 G9: ServerArray read as System.String[]).
public class ValueFormatterTests
{
/// A string array (e.g. ServerArray i=2254) prints its elements in order.
[Fact]
public void String_array_prints_elements() =>
ValueFormatter.Format(new[] { "urn:OtOpcUa:central-1", "urn:OtOpcUa:central-2" })
.ShouldBe("[urn:OtOpcUa:central-1, urn:OtOpcUa:central-2]");
/// An empty array prints as [], distinguishable from a null value.
[Fact]
public void Empty_array_prints_brackets() => ValueFormatter.Format(Array.Empty()).ShouldBe("[]");
/// Numeric arrays use the invariant culture.
[Fact]
public void Numeric_array_is_invariant() => ValueFormatter.Format(new[] { 1.5, 2.25 }).ShouldBe("[1.5, 2.25]");
/// A byte string prints as hex rather than a list of bytes.
[Fact]
public void Byte_string_prints_hex() => ValueFormatter.Format(new byte[] { 0x0A, 0xFF }).ShouldBe("0x0AFF");
/// A string is not treated as a collection of characters.
[Fact]
public void String_is_not_enumerated() => ValueFormatter.Format("abc").ShouldBe("abc");
/// Scalars and null keep their plain rendering.
[Fact]
public void Scalars_and_null() { ValueFormatter.Format(250).ShouldBe("250"); ValueFormatter.Format(null).ShouldBe(""); }
}