namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.Drivers;

/// <summary>
///     The shared golden corpus of <c>TagConfig</c> JSON blobs used to characterise the cross-driver
///     platform-intent parse (<c>TagConfigIntent.Parse</c>: alarm / isHistorized / historianTagname /
///     isArray / arrayLength). v3: the retired <c>FullName</c> key is gone — a raw tag's driver address is
///     an ordinary driver-specific key (e.g. <c>address</c>), and the tag's RawPath (not any in-blob
///     FullName) is its identity. Each entry is a NON-NULL string (the DB <c>CK_Tag_TagConfig</c> constraint
///     guarantees non-null) so the v3 round-trip parity test (<see cref="TagConfigCorpusParityTests"/>) can
///     inject each as a raw tag's <c>TagConfig</c>, flatten it through the deploy artifact into the driver's
///     <c>RawTags</c> array (keyed by RawPath), and assert the decoded <c>RawTagEntry.TagConfig</c> is
///     byte-preserved AND parses to the identical <c>TagConfigIntent</c> — the cross-seam parse-agreement
///     guarantee, now over the raw path rather than the retired equipment-tag path.
///     <para>Covers: happy path, blank, non-object root, malformed JSON, driver-only keys,
///     alarm object with each field absent/wrong-type, historizeToAveva true/false/non-bool,
///     historianTagname whitespace, isArray/arrayLength combinations (incl. negative/overflow/non-number/
///     length-without-flag/zero), unknown keys, and mixed platform+driver keys.</para>
/// </summary>
public static class TagConfigGoldenCorpus
{
    /// <summary>The corpus blobs, index-ordered. The parity test builds one raw tag per blob.</summary>
    public static readonly IReadOnlyList<string> Blobs = new[]
    {
        // 0 happy path (plain driver address, no platform intents)
        "{\"address\":\"40001\"}",
        // 1 blank (whitespace) — never-throws, no intents
        "   ",
        // 2 non-object root
        "[1,2]",
        // 3 malformed JSON
        "not json {",
        // 4 driver keys only — no platform intents
        "{\"region\":\"HoldingRegisters\",\"address\":5}",
        // 5 numeric address value — no platform intents
        "{\"address\":123}",
        // 6 whitespace address value — no platform intents
        "{\"address\":\"   \"}",
        // 7 alarm empty object → defaults (AlarmCondition, 500, historize null)
        "{\"address\":\"A\",\"alarm\":{}}",
        // 8 alarm fully specified
        "{\"address\":\"A\",\"alarm\":{\"alarmType\":\"OffNormalAlarm\",\"severity\":700}}",
        // 9 alarm non-object → no alarm
        "{\"address\":\"A\",\"alarm\":\"oops\"}",
        // 10 alarm historizeToAveva true
        "{\"address\":\"A\",\"alarm\":{\"alarmType\":\"LimitAlarm\",\"severity\":500,\"historizeToAveva\":true}}",
        // 11 alarm historizeToAveva false
        "{\"address\":\"A\",\"alarm\":{\"alarmType\":\"LimitAlarm\",\"severity\":500,\"historizeToAveva\":false}}",
        // 12 alarm historizeToAveva non-bool → null
        "{\"address\":\"A\",\"alarm\":{\"alarmType\":\"LimitAlarm\",\"severity\":500,\"historizeToAveva\":\"oops\"}}",
        // 13 alarm severity non-number → 500
        "{\"address\":\"A\",\"alarm\":{\"severity\":\"high\"}}",
        // 14 alarm alarmType non-string → AlarmCondition
        "{\"address\":\"A\",\"alarm\":{\"alarmType\":123}}",
        // 15 isHistorized true
        "{\"address\":\"A\",\"isHistorized\":true}",
        // 16 isHistorized true + explicit tagname
        "{\"address\":\"A\",\"isHistorized\":true,\"historianTagname\":\"P.L.X\"}",
        // 17 isHistorized false + JSON-null tagname
        "{\"address\":\"A\",\"isHistorized\":false,\"historianTagname\":null}",
        // 18 historianTagname whitespace → null
        "{\"address\":\"A\",\"isHistorized\":true,\"historianTagname\":\"   \"}",
        // 19 isHistorized non-bool → false
        "{\"address\":\"A\",\"isHistorized\":\"yes\"}",
        // 20 isArray true + length
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":16}",
        // 21 isArray true, no length
        "{\"address\":\"A\",\"isArray\":true}",
        // 22 isArray false + length → scalar
        "{\"address\":\"A\",\"isArray\":false,\"arrayLength\":16}",
        // 23 isArray true, length 0 → true, 0
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":0}",
        // 24 arrayLength non-number → true, null
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":\"16\"}",
        // 25 arrayLength negative → true, null
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":-1}",
        // 26 arrayLength float → true, null
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":16.5}",
        // 27 arrayLength overflow (uint.MaxValue + 1) → true, null
        "{\"address\":\"A\",\"isArray\":true,\"arrayLength\":4294967296}",
        // 28 unknown + mixed platform/driver keys
        "{\"address\":5,\"region\":\"Coils\",\"dataType\":\"Int16\",\"isHistorized\":true,\"alarm\":{\"severity\":250},\"foo\":\"bar\"}",
        // 29 all intents combined
        "{\"address\":\"C.D\",\"isArray\":true,\"arrayLength\":4,\"isHistorized\":true,\"historianTagname\":\"H\",\"alarm\":{\"alarmType\":\"DiscreteAlarm\",\"severity\":900,\"historizeToAveva\":false}}",
    };
}
