using Xunit; using Svrnty.MCP.Gateway.Core.Configuration; using Svrnty.MCP.Gateway.Core.Models; namespace Svrnty.MCP.Gateway.Core.Tests.Configuration; /// /// Unit tests for GatewayConfig following TDD approach. /// Tests gateway configuration and validation. /// public class GatewayConfigTests { [Fact] public void GatewayConfig_WithDefaultValues_CreatesSuccessfully() { // Arrange & Act var config = new GatewayConfig(); // Assert Assert.NotNull(config); Assert.NotNull(config.Servers); Assert.Empty(config.Servers); Assert.NotNull(config.Routing); Assert.NotNull(config.Security); } [Fact] public void GatewayConfig_WithServers_StoresCorrectly() { // Arrange & Act var config = new GatewayConfig { Servers = new List { new ServerConfig { Id = "server-1", Name = "Server 1" }, new ServerConfig { Id = "server-2", Name = "Server 2" } } }; // Assert Assert.Equal(2, config.Servers.Count); Assert.Contains(config.Servers, s => s.Id == "server-1"); Assert.Contains(config.Servers, s => s.Id == "server-2"); } [Fact] public void GatewayConfig_WithRoutingConfig_StoresCorrectly() { // Arrange & Act var routingConfig = new RoutingConfig { Strategy = "RoundRobin" }; var config = new GatewayConfig { Routing = routingConfig }; // Assert Assert.NotNull(config.Routing); Assert.Equal("RoundRobin", config.Routing.Strategy); } [Fact] public void GatewayConfig_WithSecurityConfig_StoresCorrectly() { // Arrange & Act var securityConfig = new SecurityConfig { EnableAuthentication = true }; var config = new GatewayConfig { Security = securityConfig }; // Assert Assert.NotNull(config.Security); Assert.True(config.Security.EnableAuthentication); } [Fact] public void GatewayConfig_Validate_WithValidConfig_ReturnsTrue() { // Arrange var config = new GatewayConfig { Servers = new List { new ServerConfig { Id = "server-1", Name = "Server 1", TransportType = "Stdio" } }, Routing = new RoutingConfig { Strategy = "RoundRobin" }, Security = new SecurityConfig { EnableAuthentication = false } }; // Act var isValid = config.Validate(); // Assert Assert.True(isValid); } [Fact] public void GatewayConfig_Validate_WithEmptyServers_ReturnsFalse() { // Arrange var config = new GatewayConfig { Servers = new List(), Routing = new RoutingConfig { Strategy = "RoundRobin" } }; // Act var isValid = config.Validate(); // Assert Assert.False(isValid); } }