using Microsoft.Extensions.Options;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.TestSupport;
///
/// Minimal test double with a mutable
/// so a test can flip a value mid-run and assert the NEXT read observes it
/// — used by the hot-toggle tests
/// (SiteRuntimeOptions.PerRunScriptEvents/PerRunScriptEventScripts are read via
/// IOptionsMonitor.CurrentValue per run specifically so they don't need a restart).
/// Avoids depending on Microsoft.Extensions.Configuration's reload-token plumbing,
/// which is awkward to drive deterministically from xUnit.
///
public sealed class TestOptionsMonitor(T initial) : IOptionsMonitor
{
private T _current = initial;
/// Gets the current value, as most recently set by .
public T CurrentValue => _current;
/// Returns the current value regardless of the requested name.
/// The named-options key, ignored by this double.
/// The current value.
public T Get(string? name) => _current;
/// Change notifications are not supported by this double; no registration is made.
/// The change listener, ignored by this double.
/// Always .
public IDisposable? OnChange(Action listener) => null;
/// Replaces the current value, observed by the next read.
/// The new value.
public void Set(T value) => _current = value;
}