698703744f
Task 9: DiscoverTreeAsync UntilStable settle loop (FOCAS) — re-capture on a 1s interval until
the node set is non-empty and stable across two passes, bounded by open-timeout; on
timeout with a prior non-empty capture, return it (best-effort) instead of failing.
Task 11: BrowserSessionService resolves bespoke-first, falls back to IUniversalDriverBrowser
when no bespoke browser matches and CanBrowse is true; new CanBrowse on the service.
16 unit tests green (4 settle + 12 service).
21 lines
1.1 KiB
C#
21 lines
1.1 KiB
C#
using ZB.MOM.WW.OtOpcUa.Commons.Browsing;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Browsing;
|
|
|
|
/// <summary>Test double for <see cref="IUniversalDriverBrowser"/>. CanBrowse is driven by a
|
|
/// predicate (default: never); OpenAsync delegates to a handler or returns a fresh session.</summary>
|
|
internal sealed class FakeUniversalDriverBrowser : IUniversalDriverBrowser
|
|
{
|
|
/// <summary>CanBrowse gate. Defaults to "no universal affordance for any type".</summary>
|
|
public Func<string, string, bool> CanBrowsePredicate { get; init; } = (_, _) => false;
|
|
|
|
/// <summary>OpenAsync behavior. Defaults to a fresh FakeBrowseSession.</summary>
|
|
public Func<string, string, CancellationToken, Task<IBrowseSession>> OpenHandler { get; init; } =
|
|
(_, _, _) => Task.FromResult<IBrowseSession>(new FakeBrowseSession());
|
|
|
|
public bool CanBrowse(string driverType, string configJson) => CanBrowsePredicate(driverType, configJson);
|
|
|
|
public Task<IBrowseSession> OpenAsync(string driverType, string configJson, CancellationToken ct) =>
|
|
OpenHandler(driverType, configJson, ct);
|
|
}
|