using ZB.MOM.WW.OtOpcUa.Core.Abstractions; namespace ZB.MOM.WW.OtOpcUa.Driver.S7.Tests; /// /// Shared in-memory recorder used across the S7 driver /// test suite. Captures every folder + variable the driver projects via /// so a test can assert the discovered shape without a /// live address space. Replaces the three structurally-identical per-file recorders /// (RecordingAddressSpaceBuilder/RecordingBuilder/CapturingBuilder) that /// previously duplicated this code. /// internal sealed class RecordingAddressSpaceBuilder : IAddressSpaceBuilder { /// Browse names of every folder the driver created, in order. public readonly List Folders = new(); /// Every variable the driver created, as (browse name, attribute info) pairs. public readonly List<(string Name, DriverAttributeInfo Attr)> Variables = new(); /// Records the folder browse name and returns this builder for chaining. /// The browse name of the folder. /// The display name of the folder. /// This builder instance for method chaining. public IAddressSpaceBuilder Folder(string browseName, string displayName) { Folders.Add(browseName); return this; } /// Records the variable's browse name + attribute info. /// The browse name of the variable. /// The display name of the variable. /// The attribute information for the variable. /// A stub handle. public IVariableHandle Variable(string browseName, string displayName, DriverAttributeInfo attributeInfo) { Variables.Add((browseName, attributeInfo)); return new StubHandle(); } /// No-op property sink — the S7 driver does not add properties. /// The browse name of the property. /// The data type of the property. /// The initial value of the property. public void AddProperty(string browseName, DriverDataType dataType, object? value) { } /// No-op alarm sink — the S7 driver never surfaces alarms. /// The variable to attach the alarm to. /// The name of the alarm. /// The alarm information. public void AttachAlarmCondition(IVariableHandle sourceVariable, string alarmName, DriverAttributeInfo alarmInfo) { } private sealed class StubHandle : IVariableHandle { /// Gets the full reference of the variable. public string FullReference => "stub"; /// Marks this variable as an alarm condition. /// The alarm condition information. /// An alarm condition sink. public IAlarmConditionSink MarkAsAlarmCondition(AlarmConditionInfo info) => throw new NotImplementedException("S7 driver never calls this — no alarm surfacing"); } }