Refactor transports to help enable graceful shutdown (#142)
- This also paves the way for better multi-session support - We should definitely rethink names for the transport API - For now, I kept the names similar as possible, so we can focus on the API shape Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
d47c834fa9
commit
2ab9db0878
1 changed files with 2015 additions and 1847 deletions
|
|
@ -3,6 +3,7 @@ using ModelContextProtocol.Client;
|
|||
using ModelContextProtocol.Configuration;
|
||||
using ModelContextProtocol.Protocol.Transport;
|
||||
using ModelContextProtocol.Test.Utils;
|
||||
using ModelContextProtocol.Tests.Utils;
|
||||
using ModelContextProtocol.TestSseServer;
|
||||
|
||||
namespace ModelContextProtocol.Tests;
|
||||
|
|
@ -47,6 +48,11 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
|||
_delegatingTestOutputHelper.CurrentTestOutputHelper = output;
|
||||
}
|
||||
|
||||
public void TestCompleted()
|
||||
{
|
||||
_delegatingTestOutputHelper.CurrentTestOutputHelper = null;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_delegatingTestOutputHelper.CurrentTestOutputHelper = null;
|
||||
|
|
@ -61,16 +67,4 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
|||
_redirectingLoggerFactory.Dispose();
|
||||
_stopCts.Dispose();
|
||||
}
|
||||
|
||||
private class DelegatingTestOutputHelper() : ITestOutputHelper
|
||||
{
|
||||
public ITestOutputHelper? CurrentTestOutputHelper { get; set; }
|
||||
|
||||
public string Output => CurrentTestOutputHelper?.Output ?? string.Empty;
|
||||
|
||||
public void Write(string message) => CurrentTestOutputHelper?.Write(message);
|
||||
public void Write(string format, params object[] args) => CurrentTestOutputHelper?.Write(format, args);
|
||||
public void WriteLine(string message) => CurrentTestOutputHelper?.WriteLine(message);
|
||||
public void WriteLine(string format, params object[] args) => CurrentTestOutputHelper?.WriteLine(format, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue