using System.Text.Json; using System.Text.Json.Serialization; using Moq; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates; using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services; using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; using ZB.MOM.WW.ScadaBridge.Commons.Types.Templates; namespace ZB.MOM.WW.ScadaBridge.TemplateEngine.Tests; /// /// Gitea #86: TemplateService.ReconcileDescendantsAsync now reconciles against the /// template's derived subtree + inheritance chain instead of the whole tracked library. These /// tests pin that the closure is (a) sufficient — for every template of a graph with a deep /// subtree, an ancestor chain above the edited template, a composed module, unrelated look-alike /// trees, a parent cycle and a dangling parent, the reconcile issues exactly the same writes and /// the resolver answers identically for every descendant — and (b) actually smaller, loading /// nothing beyond one probe when there are no descendants. /// public class TemplateReconcileClosureTests { internal const int Root = 1, Base = 2, Mid = 3, Leaf1 = 4, Leaf2 = 5, Leaf3 = 6, GreatLeaf = 7, Mod = 8; internal const int U1 = 9, U2 = 10, CycA = 11, CycB = 12, CycC = 13, Dang = 14, DangKid = 15; internal static readonly JsonSerializerOptions Json = new() { ReferenceHandler = ReferenceHandler.IgnoreCycles, WriteIndented = false, }; /// Builds a fresh, independently mutable copy of the fixture graph. internal static List