- Renamed all directories: OpenHarbor.MCP.* → Svrnty.MCP.* - Updated all namespaces in 179 C# files - Renamed 20 .csproj files and 3 .sln files - Updated 193 documentation references - Updated 33 references in main CODEX codebase - Updated Codex.sln with new paths - Build verified: 0 errors Preparing for extraction to standalone repositories. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
114 lines
3.0 KiB
C#
114 lines
3.0 KiB
C#
using Xunit;
|
|
using Svrnty.MCP.Gateway.Core.Configuration;
|
|
using Svrnty.MCP.Gateway.Core.Models;
|
|
|
|
namespace Svrnty.MCP.Gateway.Core.Tests.Configuration;
|
|
|
|
/// <summary>
|
|
/// Unit tests for GatewayConfig following TDD approach.
|
|
/// Tests gateway configuration and validation.
|
|
/// </summary>
|
|
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<ServerConfig>
|
|
{
|
|
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<ServerConfig>
|
|
{
|
|
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<ServerConfig>(),
|
|
Routing = new RoutingConfig { Strategy = "RoundRobin" }
|
|
};
|
|
|
|
// Act
|
|
var isValid = config.Validate();
|
|
|
|
// Assert
|
|
Assert.False(isValid);
|
|
}
|
|
}
|