- 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>
128 lines
3.0 KiB
C#
128 lines
3.0 KiB
C#
using Xunit;
|
|
using Svrnty.MCP.Gateway.Core.Configuration;
|
|
|
|
namespace Svrnty.MCP.Gateway.Core.Tests.Configuration;
|
|
|
|
/// <summary>
|
|
/// Unit tests for RoutingConfig following TDD approach.
|
|
/// Tests routing configuration and validation.
|
|
/// </summary>
|
|
public class RoutingConfigTests
|
|
{
|
|
[Fact]
|
|
public void RoutingConfig_DefaultStrategy_IsRoundRobin()
|
|
{
|
|
// Arrange & Act
|
|
var config = new RoutingConfig();
|
|
|
|
// Assert
|
|
Assert.Equal("RoundRobin", config.Strategy);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_WithCustomStrategy_StoresCorrectly()
|
|
{
|
|
// Arrange & Act
|
|
var config = new RoutingConfig
|
|
{
|
|
Strategy = "ToolBased",
|
|
ToolMapping = new Dictionary<string, string>
|
|
{
|
|
{ "search_*", "server-1" },
|
|
{ "get_*", "server-2" }
|
|
}
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal("ToolBased", config.Strategy);
|
|
Assert.NotNull(config.ToolMapping);
|
|
Assert.Equal(2, config.ToolMapping.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_WithClientBasedStrategy_StoresClientMapping()
|
|
{
|
|
// Arrange & Act
|
|
var config = new RoutingConfig
|
|
{
|
|
Strategy = "ClientBased",
|
|
ClientMapping = new Dictionary<string, string>
|
|
{
|
|
{ "web-client", "server-1" },
|
|
{ "mobile-client", "server-2" }
|
|
}
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal("ClientBased", config.Strategy);
|
|
Assert.NotNull(config.ClientMapping);
|
|
Assert.Equal("server-1", config.ClientMapping["web-client"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_WithRetrySettings_StoresCorrectly()
|
|
{
|
|
// Arrange & Act
|
|
var config = new RoutingConfig
|
|
{
|
|
EnableRetry = true,
|
|
MaxRetryAttempts = 3,
|
|
RetryDelayMs = 1000
|
|
};
|
|
|
|
// Assert
|
|
Assert.True(config.EnableRetry);
|
|
Assert.Equal(3, config.MaxRetryAttempts);
|
|
Assert.Equal(1000, config.RetryDelayMs);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_Validate_WithValidStrategy_ReturnsTrue()
|
|
{
|
|
// Arrange
|
|
var config = new RoutingConfig
|
|
{
|
|
Strategy = "RoundRobin"
|
|
};
|
|
|
|
// Act
|
|
var isValid = config.Validate();
|
|
|
|
// Assert
|
|
Assert.True(isValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_Validate_WithInvalidStrategy_ReturnsFalse()
|
|
{
|
|
// Arrange
|
|
var config = new RoutingConfig
|
|
{
|
|
Strategy = "InvalidStrategy"
|
|
};
|
|
|
|
// Act
|
|
var isValid = config.Validate();
|
|
|
|
// Assert
|
|
Assert.False(isValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoutingConfig_Validate_ToolBasedWithoutMapping_ReturnsFalse()
|
|
{
|
|
// Arrange
|
|
var config = new RoutingConfig
|
|
{
|
|
Strategy = "ToolBased",
|
|
ToolMapping = null
|
|
};
|
|
|
|
// Act
|
|
var isValid = config.Validate();
|
|
|
|
// Assert
|
|
Assert.False(isValid);
|
|
}
|
|
}
|