- 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>
148 lines
3.5 KiB
C#
148 lines
3.5 KiB
C#
using Svrnty.MCP.Client.Core.Models;
|
|
using Xunit;
|
|
|
|
namespace Svrnty.MCP.Client.Core.Tests.Models;
|
|
|
|
/// <summary>
|
|
/// Unit tests for McpServerConfig and transport configurations.
|
|
/// Tests configuration creation and default values.
|
|
/// </summary>
|
|
public class McpServerConfigTests
|
|
{
|
|
[Fact]
|
|
public void Constructor_WithStdioTransport_CreatesConfig()
|
|
{
|
|
// Arrange
|
|
var transport = new StdioTransportConfig
|
|
{
|
|
Type = "Stdio",
|
|
Command = "dotnet",
|
|
Args = new[] { "run", "--project", "test.csproj" }
|
|
};
|
|
|
|
// Act
|
|
var config = new McpServerConfig
|
|
{
|
|
Name = "test-server",
|
|
Transport = transport
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal("test-server", config.Name);
|
|
Assert.IsType<StdioTransportConfig>(config.Transport);
|
|
Assert.Equal(TimeSpan.FromSeconds(30), config.Timeout);
|
|
Assert.True(config.Enabled);
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_WithHttpTransport_CreatesConfig()
|
|
{
|
|
// Arrange
|
|
var transport = new HttpTransportConfig
|
|
{
|
|
Type = "Http",
|
|
BaseUrl = "https://api.example.com/mcp"
|
|
};
|
|
|
|
// Act
|
|
var config = new McpServerConfig
|
|
{
|
|
Name = "http-server",
|
|
Transport = transport
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal("http-server", config.Name);
|
|
Assert.IsType<HttpTransportConfig>(config.Transport);
|
|
Assert.Equal("https://api.example.com/mcp", ((HttpTransportConfig)config.Transport).BaseUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_WithCustomTimeout_SetsTimeout()
|
|
{
|
|
// Arrange
|
|
var transport = new StdioTransportConfig
|
|
{
|
|
Type = "Stdio",
|
|
Command = "node",
|
|
Args = new[] { "server.js" }
|
|
};
|
|
|
|
// Act
|
|
var config = new McpServerConfig
|
|
{
|
|
Name = "custom-timeout-server",
|
|
Transport = transport,
|
|
Timeout = TimeSpan.FromMinutes(5)
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal(TimeSpan.FromMinutes(5), config.Timeout);
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_WithEnabledFalse_SetsEnabledFalse()
|
|
{
|
|
// Arrange
|
|
var transport = new StdioTransportConfig
|
|
{
|
|
Type = "Stdio",
|
|
Command = "test"
|
|
};
|
|
|
|
// Act
|
|
var config = new McpServerConfig
|
|
{
|
|
Name = "disabled-server",
|
|
Transport = transport,
|
|
Enabled = false
|
|
};
|
|
|
|
// Assert
|
|
Assert.False(config.Enabled);
|
|
}
|
|
|
|
[Fact]
|
|
public void StdioTransportConfig_WithEmptyArgs_HasEmptyArray()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new StdioTransportConfig
|
|
{
|
|
Type = "Stdio",
|
|
Command = "test"
|
|
};
|
|
|
|
// Assert
|
|
Assert.Empty(transport.Args);
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransportConfig_WithApiKey_StoresApiKey()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new HttpTransportConfig
|
|
{
|
|
Type = "Http",
|
|
BaseUrl = "https://secure.example.com/mcp",
|
|
ApiKey = "test-api-key-123"
|
|
};
|
|
|
|
// Assert
|
|
Assert.Equal("test-api-key-123", transport.ApiKey);
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransportConfig_WithoutApiKey_HasNullApiKey()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new HttpTransportConfig
|
|
{
|
|
Type = "Http",
|
|
BaseUrl = "https://public.example.com/mcp"
|
|
};
|
|
|
|
// Assert
|
|
Assert.Null(transport.ApiKey);
|
|
}
|
|
}
|