Fix private reflection (#60)

* Fix private reflection

Two changes in this PR

- Remove private reflection from one of the tests
- Move to use `TaskCompletionSource` (feedback from previous PR)

* fix

* spelling
This commit is contained in:
Jared Parsons 2025-03-22 09:09:43 -07:00 • committed by GitHub
commit e76dbb5372
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,10 +89,12 @@ public class McpServerTests
{
// Arrange
await using var server = McpServerFactory.Create(_serverTransport.Object, _options, _loggerFactory.Object, _serviceProvider);
server.GetType().GetField("_isInitializing", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(server, true);
var task = server.StartAsync(TestContext.Current.CancellationToken);
// Act & Assert
await Assert.ThrowsAsync<InvalidOperationException>(() => server.StartAsync(TestContext.Current.CancellationToken));
await task;
}
[Fact]