using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using StellaOps.Router.Gateway.Configuration; using StellaOps.Router.Gateway.DependencyInjection; using Xunit; namespace StellaOps.Router.Gateway.Tests; public sealed class RouterNodeConfigValidationTests { [Fact] public void RouterNodeConfig_WhenRegionMissing_ThrowsOptionsValidationException() { var services = new ServiceCollection(); services.AddRouterGatewayCore(); using var provider = services.BuildServiceProvider(); var act = () => provider.GetRequiredService>().Value; act.Should().Throw(); } [Fact] public void RouterNodeConfig_WhenRegionProvided_GeneratesNodeIdIfMissing() { var services = new ServiceCollection(); services.AddRouterGatewayCore(); services.Configure(c => c.Region = "test"); using var provider = services.BuildServiceProvider(); var config = provider.GetRequiredService>().Value; config.Region.Should().Be("test"); config.NodeId.Should().StartWith("gw-test-"); config.NodeId.Should().HaveLength("gw-test-".Length + 8); } }