using ZB.MOM.WW.OtOpcUa.Commons.Browsing; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Browsing; /// Test double for used by the registry, reaper, /// and service tests. All three operations delegate to caller-supplied handlers so each /// test can shape behaviour; records that it ran and can be /// instructed to throw via . internal sealed class FakeBrowseSession : IBrowseSession { /// public Guid Token { get; } = Guid.NewGuid(); /// Mutable so tests can rewind the timestamp into the reaper's eviction window. public DateTime LastUsedUtc { get; set; } = DateTime.UtcNow; /// True once has run to completion. public bool Disposed { get; private set; } /// When true, throws to exercise the reaper's /// best-effort dispose path. public bool ThrowOnDispose { get; set; } // Suppress CS0649: handlers are test seams — some tests leave them null intentionally. #pragma warning disable CS0649 public Func>>? RootHandler; public Func>>? ExpandHandler; public Func>>? AttributesHandler; #pragma warning restore CS0649 /// public Task> RootAsync(CancellationToken ct) => RootHandler?.Invoke(ct) ?? Task.FromResult>(Array.Empty()); /// public Task> ExpandAsync(string nodeId, CancellationToken ct) => ExpandHandler?.Invoke(nodeId, ct) ?? Task.FromResult>(Array.Empty()); /// public Task> AttributesAsync(string nodeId, CancellationToken ct) => AttributesHandler?.Invoke(nodeId, ct) ?? Task.FromResult>(Array.Empty()); /// public ValueTask DisposeAsync() { if (ThrowOnDispose) throw new InvalidOperationException("dispose-failed"); Disposed = true; return ValueTask.CompletedTask; } }