- 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>
129 lines
3.4 KiB
C#
129 lines
3.4 KiB
C#
using Xunit;
|
|
using Svrnty.MCP.Gateway.Infrastructure.Transport;
|
|
using Svrnty.MCP.Gateway.Core.Models;
|
|
|
|
namespace Svrnty.MCP.Gateway.Infrastructure.Tests.Transport;
|
|
|
|
/// <summary>
|
|
/// Unit tests for transport factory logic.
|
|
/// Tests transport creation based on server configuration.
|
|
/// </summary>
|
|
public class TransportFactoryTests
|
|
{
|
|
[Fact]
|
|
public void StdioTransport_WithValidCommand_CreatesSuccessfully()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new StdioServerTransport("echo", new[] { "test" });
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
Assert.False(transport.IsConnected);
|
|
}
|
|
|
|
[Fact]
|
|
public void StdioTransport_WithEmptyArgs_CreatesSuccessfully()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new StdioServerTransport("ls", Array.Empty<string>());
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransport_WithValidUrl_CreatesSuccessfully()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new HttpServerTransport("http://localhost:8080");
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
Assert.False(transport.IsConnected);
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransport_WithHttpsUrl_CreatesSuccessfully()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new HttpServerTransport("https://api.example.com");
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
}
|
|
|
|
[Fact]
|
|
public void StdioTransport_WithNullArgs_UsesEmptyArray()
|
|
{
|
|
// Arrange & Act
|
|
var transport = new StdioServerTransport("echo", null!);
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("http://localhost:5000")]
|
|
[InlineData("https://api.example.com:8443")]
|
|
[InlineData("http://192.168.1.1:3000")]
|
|
public void HttpTransport_WithVariousUrls_CreatesSuccessfully(string baseUrl)
|
|
{
|
|
// Arrange & Act
|
|
var transport = new HttpServerTransport(baseUrl);
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
Assert.False(transport.IsConnected);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("dotnet", "run")]
|
|
[InlineData("python3", "server.py")]
|
|
[InlineData("node", "index.js")]
|
|
public void StdioTransport_WithVariousCommands_CreatesSuccessfully(string command, string arg)
|
|
{
|
|
// Arrange & Act
|
|
var transport = new StdioServerTransport(command, new[] { arg });
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
}
|
|
|
|
[Fact]
|
|
public void StdioTransport_Dispose_CanBeCalledMultipleTimes()
|
|
{
|
|
// Arrange
|
|
var transport = new StdioServerTransport("echo", new[] { "test" });
|
|
|
|
// Act & Assert - should not throw
|
|
transport.Dispose();
|
|
transport.Dispose();
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransport_Dispose_CanBeCalledMultipleTimes()
|
|
{
|
|
// Arrange
|
|
var httpClient = new HttpClient();
|
|
var transport = new HttpServerTransport("http://localhost:5000", httpClient);
|
|
|
|
// Act & Assert - should not throw
|
|
transport.Dispose();
|
|
transport.Dispose();
|
|
}
|
|
|
|
[Fact]
|
|
public void HttpTransport_WithCustomHttpClient_UsesProvidedClient()
|
|
{
|
|
// Arrange
|
|
var customHttpClient = new HttpClient();
|
|
customHttpClient.Timeout = TimeSpan.FromSeconds(5);
|
|
|
|
// Act
|
|
var transport = new HttpServerTransport("http://localhost:5000", customHttpClient);
|
|
|
|
// Assert
|
|
Assert.NotNull(transport);
|
|
}
|
|
}
|