Reorganize folders, samples, minor bug fix (#14)
Reorganize folders Samples Casing fixes
This commit is contained in:
parent
e51c78e5e4
commit
3e35efe79c
1 changed files with 501 additions and 20 deletions
|
|
@ -1,74 +0,0 @@
|
|||
using McpDotNet.Configuration;
|
||||
using McpDotNet.Protocol.Messages;
|
||||
using McpDotNet.Protocol.Transport;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace McpDotNet.Tests.Client;
|
||||
|
||||
public class SseTransportTests
|
||||
{
|
||||
[Fact]
|
||||
public void SseTransportConstructor_WithValidConfig_CreatesTransport()
|
||||
{
|
||||
// Arrange
|
||||
var config = new McpServerConfig
|
||||
{
|
||||
Id = "test-server",
|
||||
Name = "Test Server",
|
||||
TransportType = "sse",
|
||||
Location = "http://localhost:8080"
|
||||
};
|
||||
|
||||
var transportOptions = new SseTransportOptions
|
||||
{
|
||||
ConnectionTimeout = TimeSpan.FromSeconds(10),
|
||||
MaxReconnectAttempts = 2,
|
||||
ReconnectDelay = TimeSpan.FromSeconds(5),
|
||||
AdditionalHeaders = new Dictionary<string, string>
|
||||
{
|
||||
["test"] = "header"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var transport = new SseTransport(transportOptions, config, NullLoggerFactory.Instance);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(transport);
|
||||
Assert.True(transport.Options.ConnectionTimeout == TimeSpan.FromSeconds(10));
|
||||
Assert.True(transport.Options.MaxReconnectAttempts == 2);
|
||||
Assert.True(transport.Options.ReconnectDelay == TimeSpan.FromSeconds(5));
|
||||
Assert.True(transport.Options.AdditionalHeaders["test"] == "header");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void SseTransportSendMessageAsync_WithMessageEndpointNotSet_ThrowsException()
|
||||
{
|
||||
// Arrange
|
||||
var config = new McpServerConfig
|
||||
{
|
||||
Id = "test-server",
|
||||
Name = "Test Server",
|
||||
TransportType = "sse",
|
||||
Location = "http://localhost:8080"
|
||||
};
|
||||
|
||||
var transportOptions = new SseTransportOptions
|
||||
{
|
||||
ConnectionTimeout = TimeSpan.FromSeconds(10),
|
||||
MaxReconnectAttempts = 2,
|
||||
ReconnectDelay = TimeSpan.FromSeconds(5),
|
||||
AdditionalHeaders = new Dictionary<string, string>
|
||||
{
|
||||
["test"] = "header"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var transport = new SseTransport(transportOptions, config, NullLoggerFactory.Instance);
|
||||
|
||||
// Assert
|
||||
Assert.True(string.IsNullOrEmpty(transport.MessageEndpoint?.ToString()));
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() => transport.SendMessageAsync(new JsonRpcRequest() { Method = "test"}, CancellationToken.None));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue