using Opc.Ua; namespace ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests; /// Observes wire payloads using the CLR representations asserted by the baseline contract tests. internal static class SdkTestValues { internal static object? ClrValue(this DataValue value) => value.WrappedValue.ClrValue(); internal static object? ClrValue(this Variant value) => value.AsBoxedObject(Variant.BoxingBehavior.Legacy) switch { ByteString bytes => bytes.IsNull ? null : bytes.ToArray(), DateTimeUtc time => (DateTime)time, Uuid id => (Guid)id, var other => other, }; internal static Variant FromClr(object? value) { if (value is null) return Variant.Null; if (value is byte[] bytes) return Variant.From(ByteString.From(bytes)); if (VariantHelper.TryCastFrom(value, out var variant)) return variant; throw new ArgumentException("Unsupported test payload.", nameof(value)); } }