Add ci build workflow (#31)
* Add ci build workflow * Using cake build * Update readme
This commit is contained in:
parent
257a97a659
commit
80daa5b73d
3 changed files with 303 additions and 20 deletions
|
|
@ -6,6 +6,7 @@ using OpenAI;
|
|||
|
||||
namespace McpDotNet.Extensions.AI.Tests;
|
||||
|
||||
[Trait("Execution", "Manual")]
|
||||
public class IntegrationTests
|
||||
{
|
||||
private const string OpenAIKey = ""; // Provide your own key when running the test. Do not commit it.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using McpDotNet.Protocol.Types;
|
|||
|
||||
namespace McpDotNet.Tests;
|
||||
|
||||
[Trait("Execution", "Manual")]
|
||||
public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture>
|
||||
{
|
||||
private readonly ClientIntegrationTestFixture _fixture;
|
||||
|
|
@ -18,7 +19,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
public async Task ConnectAndPing_Stdio_EverythingServer()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
|
||||
// Act
|
||||
var client = await _fixture.Factory.GetClientAsync("everything");
|
||||
await client.PingAsync(CancellationToken.None);
|
||||
|
|
@ -47,7 +48,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
public async Task ListTools_Stdio_EverythingServer()
|
||||
{
|
||||
// arrange
|
||||
|
||||
|
||||
// act
|
||||
var client = await _fixture.Factory.GetClientAsync("everything");
|
||||
var tools = await client.ListToolsAsync();
|
||||
|
|
@ -62,7 +63,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
public async Task CallTool_Stdio_EchoServer()
|
||||
{
|
||||
// arrange
|
||||
|
||||
|
||||
// act
|
||||
var client = await _fixture.Factory.GetClientAsync("everything");
|
||||
var result = await client.CallToolAsync(
|
||||
|
|
@ -184,7 +185,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
public async Task ReadResource_Stdio_BinaryResource()
|
||||
{
|
||||
// arrange
|
||||
|
||||
|
||||
// act
|
||||
var client = await _fixture.Factory.GetClientAsync("everything");
|
||||
// Even numbered resources are binary in the everything server (despite the docs saying otherwise)
|
||||
|
|
@ -214,11 +215,11 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
// act
|
||||
var client = await _fixture.Factory.GetClientAsync("everything");
|
||||
var result = await client.GetCompletionAsync(new Reference
|
||||
{
|
||||
Type = "ref/resource",
|
||||
Uri = "test://static/resource/1"
|
||||
},
|
||||
"argument_name", "1",
|
||||
{
|
||||
Type = "ref/resource",
|
||||
Uri = "test://static/resource/1"
|
||||
},
|
||||
"argument_name", "1",
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
|
|
@ -249,7 +250,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
Type = "ref/prompt",
|
||||
Name = "irrelevant"
|
||||
},
|
||||
argumentName:"style", argumentValue:"fo",
|
||||
argumentName: "style", argumentValue: "fo",
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
|
|
@ -293,7 +294,7 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
// Set up the sampling handler
|
||||
int samplingHandlerCalls = 0;
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
client.SamplingHandler = async (_,_) =>
|
||||
client.SamplingHandler = async (_, _) =>
|
||||
{
|
||||
samplingHandlerCalls++;
|
||||
return new CreateMessageResult
|
||||
|
|
@ -312,10 +313,10 @@ public class ClientIntegrationTests : IClassFixture<ClientIntegrationTestFixture
|
|||
// Call the server's sampleLLM tool which should trigger our sampling handler
|
||||
var result = await client.CallToolAsync(
|
||||
"sampleLLM",
|
||||
new Dictionary<string, object>
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
["prompt"] = "Test prompt",
|
||||
["maxTokens"] = 100
|
||||
["prompt"] = "Test prompt",
|
||||
["maxTokens"] = 100
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
using McpDotNet.Client;
|
||||
using System.Text.Json;
|
||||
using McpDotNet.Client;
|
||||
using McpDotNet.Configuration;
|
||||
using McpDotNet.Protocol.Messages;
|
||||
using McpDotNet.Protocol.Transport;
|
||||
using McpDotNet.Protocol.Types;
|
||||
using McpDotNet.Tests.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace McpDotNet.Tests;
|
||||
|
||||
[Trait("Execution", "Manual")]
|
||||
public class SseIntegrationTests
|
||||
{
|
||||
[Fact]
|
||||
|
|
@ -19,7 +19,7 @@ public class SseIntegrationTests
|
|||
builder.AddConsole()
|
||||
.SetMinimumLevel(LogLevel.Debug));
|
||||
|
||||
await using TestSseServer server = new(logger:loggerFactory.CreateLogger<TestSseServer>());
|
||||
await using TestSseServer server = new(logger: loggerFactory.CreateLogger<TestSseServer>());
|
||||
await server.StartAsync();
|
||||
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ public class SseIntegrationTests
|
|||
ClientInfo = new()
|
||||
{
|
||||
Name = "IntegrationTestClient",
|
||||
Version = "1.0.0"
|
||||
Version = "1.0.0"
|
||||
},
|
||||
Capabilities = new()
|
||||
{
|
||||
|
|
@ -228,7 +228,7 @@ public class SseIntegrationTests
|
|||
await using TestSseServer server = new(logger: loggerFactory.CreateLogger<TestSseServer>());
|
||||
await server.StartAsync();
|
||||
|
||||
|
||||
|
||||
var defaultOptions = new McpClientOptions
|
||||
{
|
||||
ClientInfo = new() { Name = "IntegrationTestClient", Version = "1.0.0" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue