using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Runtime.Historian;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests;
///
/// Read-cutover seam tests (T10). Both assert offline construction only — the package client builds
/// its GrpcChannel lazily, so neither the adapter ctor nor the factory dials the gateway. A
/// bogus/unreachable endpoint must therefore construct without throwing or performing network I/O.
///
public sealed class HistorianGatewayClientAdapterTests
{
[Fact]
public void Adapter_constructs_from_options_without_dialing()
{
// Constructing the channel must not perform network I/O (lazy connect).
var opts = new ServerHistorianOptions { Enabled = true, Endpoint = "https://localhost:5222", ApiKey = "histgw_x_y" };
using var adapter = HistorianGatewayClientAdapter.Create(opts, NullLoggerFactory.Instance);
Assert.NotNull(adapter);
}
[Fact]
public void Factory_builds_GatewayHistorianDataSource()
{
var opts = new ServerHistorianOptions { Enabled = true, Endpoint = "https://localhost:5222", ApiKey = "histgw_x_y" };
using var services = new ServiceCollection().BuildServiceProvider();
var dataSource = GatewayHistorian.CreateDataSource(opts, services);
Assert.IsType(dataSource);
}
}