csharp-sdk/tests/ModelContextProtocol.Tests/Server/McpServerFactoryTests.cs
Stephen Halter 973c7c093f
Add ModelContextProtocol.AspNetCore (#160)
* Add ModelContextProtocol.AspNetCore

- Remove IServerTransport and HttpListenerSseServerTransport
- Replace HttpListenerSseServerTransport usage in tests with ASP.NET Core.

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
2025-03-31 12:01:04 -07:00

47 lines
1.4 KiB
C#

using ModelContextProtocol.Protocol.Transport;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Server;
using ModelContextProtocol.Tests.Utils;
using Moq;
namespace ModelContextProtocol.Tests.Server;
public class McpServerFactoryTests : LoggedTest
{
private readonly McpServerOptions _options;
public McpServerFactoryTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
_options = new McpServerOptions
{
ServerInfo = new Implementation { Name = "TestServer", Version = "1.0" },
ProtocolVersion = "1.0",
InitializationTimeout = TimeSpan.FromSeconds(30)
};
}
[Fact]
public async Task Create_Should_Initialize_With_Valid_Parameters()
{
// Arrange & Act
await using IMcpServer server = McpServerFactory.Create(Mock.Of<ITransport>(), _options, LoggerFactory);
// Assert
Assert.NotNull(server);
}
[Fact]
public void Create_Throws_For_Null_ServerTransport()
{
// Arrange, Act & Assert
Assert.Throws<ArgumentNullException>("transport", () => McpServerFactory.Create(null!, _options, LoggerFactory));
}
[Fact]
public void Create_Throws_For_Null_Options()
{
// Arrange, Act & Assert
Assert.Throws<ArgumentNullException>("serverOptions", () => McpServerFactory.Create(Mock.Of<ITransport>(), null!, LoggerFactory));
}
}