- 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>
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
using Xunit;
|
|
using Moq;
|
|
using Svrnty.MCP.Gateway.Core.Interfaces;
|
|
using Svrnty.MCP.Gateway.Core.Models;
|
|
|
|
namespace Svrnty.MCP.Gateway.Core.Tests.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Unit tests for IServerTransport interface following TDD approach.
|
|
/// Tests transport communication contract.
|
|
/// </summary>
|
|
public class IServerTransportTests
|
|
{
|
|
[Fact]
|
|
public async Task SendRequestAsync_WithValidRequest_ReturnsResponse()
|
|
{
|
|
// Arrange
|
|
var mockTransport = new Mock<IServerTransport>();
|
|
var request = new GatewayRequest
|
|
{
|
|
ToolName = "test_tool",
|
|
Arguments = new Dictionary<string, object> { { "key", "value" } }
|
|
};
|
|
var expectedResponse = new GatewayResponse
|
|
{
|
|
Success = true,
|
|
Result = new Dictionary<string, object> { { "data", "result" } }
|
|
};
|
|
|
|
mockTransport
|
|
.Setup(t => t.SendRequestAsync(It.IsAny<GatewayRequest>(), It.IsAny<CancellationToken>()))
|
|
.ReturnsAsync(expectedResponse);
|
|
|
|
// Act
|
|
var response = await mockTransport.Object.SendRequestAsync(request, CancellationToken.None);
|
|
|
|
// Assert
|
|
Assert.NotNull(response);
|
|
Assert.True(response.Success);
|
|
mockTransport.Verify(t => t.SendRequestAsync(request, It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ConnectAsync_OpensConnection()
|
|
{
|
|
// Arrange
|
|
var mockTransport = new Mock<IServerTransport>();
|
|
mockTransport
|
|
.Setup(t => t.ConnectAsync(It.IsAny<CancellationToken>()))
|
|
.Returns(Task.CompletedTask);
|
|
|
|
// Act
|
|
await mockTransport.Object.ConnectAsync(CancellationToken.None);
|
|
|
|
// Assert
|
|
mockTransport.Verify(t => t.ConnectAsync(It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task DisconnectAsync_ClosesConnection()
|
|
{
|
|
// Arrange
|
|
var mockTransport = new Mock<IServerTransport>();
|
|
mockTransport
|
|
.Setup(t => t.DisconnectAsync(It.IsAny<CancellationToken>()))
|
|
.Returns(Task.CompletedTask);
|
|
|
|
// Act
|
|
await mockTransport.Object.DisconnectAsync(CancellationToken.None);
|
|
|
|
// Assert
|
|
mockTransport.Verify(t => t.DisconnectAsync(It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsConnected_ReturnsConnectionState()
|
|
{
|
|
// Arrange
|
|
var mockTransport = new Mock<IServerTransport>();
|
|
mockTransport.Setup(t => t.IsConnected).Returns(true);
|
|
|
|
// Act
|
|
var isConnected = mockTransport.Object.IsConnected;
|
|
|
|
// Assert
|
|
Assert.True(isConnected);
|
|
}
|
|
}
|