using Microsoft.Extensions.DependencyInjection; using ZB.MOM.WW.SPHistorianClient; namespace ZB.MOM.WW.SPHistorianClient.Tests; public class DependencyInjectionTests { [Fact] public async Task AddZbSpHistorianClient_resolves_client_and_options() { var services = new ServiceCollection(); var options = new HistorianClientOptions { Host = "localhost" }; services.AddZbSpHistorianClient(options); // HistorianClient is IAsyncDisposable-only, so the container must be disposed // asynchronously (a synchronous `using` throws InvalidOperationException). await using var sp = services.BuildServiceProvider(); Assert.Same(options, sp.GetRequiredService()); Assert.NotNull(sp.GetRequiredService()); } [Fact] public void AddZbSpHistorianClient_throws_when_host_missing() { var services = new ServiceCollection(); var options = new HistorianClientOptions { Host = "" }; Assert.Throws(() => services.AddZbSpHistorianClient(options)); } [Fact] public void AddZbSpHistorianClient_throws_on_null_options() { var services = new ServiceCollection(); Assert.Throws(() => services.AddZbSpHistorianClient(null!)); } }