Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Browsing/FakeDriverBrowser.cs
T
2026-05-28 15:44:20 -04:00

23 lines
1002 B
C#

using ZB.MOM.WW.OtOpcUa.Commons.Browsing;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Browsing;
/// <summary>Test double for <see cref="IDriverBrowser"/>. The constructor sets
/// <see cref="DriverType"/>; <see cref="OpenAsync"/> delegates to the caller-supplied
/// <see cref="OpenHandler"/> or returns a fresh <see cref="FakeBrowseSession"/>.</summary>
internal sealed class FakeDriverBrowser(string driverType) : IDriverBrowser
{
/// <inheritdoc />
public string DriverType { get; } = driverType;
/// <summary>Override for <see cref="OpenAsync"/>; if null, a fresh
/// <see cref="FakeBrowseSession"/> is returned.</summary>
#pragma warning disable CS0649
public Func<string, CancellationToken, Task<IBrowseSession>>? OpenHandler;
#pragma warning restore CS0649
/// <inheritdoc />
public Task<IBrowseSession> OpenAsync(string configJson, CancellationToken ct)
=> OpenHandler?.Invoke(configJson, ct) ?? Task.FromResult<IBrowseSession>(new FakeBrowseSession());
}