1- using Microsoft . Extensions . Logging . Abstractions ;
2-
31using ModelContextProtocol . Protocol . Messages ;
42using ModelContextProtocol . Protocol . Transport ;
53using ModelContextProtocol . Server ;
4+ using ModelContextProtocol . Tests . Utils ;
65
76namespace ModelContextProtocol . Tests . Transport ;
87
9- public class InMemoryTransportTests
8+ public class InMemoryTransportTests ( ITestOutputHelper testOutputHelper ) : LoggedTest ( testOutputHelper )
109{
1110 private readonly Type [ ] _toolTypes = [ typeof ( TestTool ) ] ;
1211
1312 [ Fact ]
1413 public async Task Constructor_Should_Initialize_With_Valid_Parameters ( )
1514 {
1615 // Act
17- await using var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
16+ await using var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
1817
1918 // Assert
2019 Assert . NotNull ( transport ) ;
@@ -24,17 +23,17 @@ public async Task Constructor_Should_Initialize_With_Valid_Parameters()
2423 public void Constructor_Throws_For_Null_Parameters ( )
2524 {
2625 Assert . Throws < ArgumentException > ( "toolTypes" ,
27- ( ) => InMemoryTransport . Create ( NullLoggerFactory . Instance , Array . Empty < Type > ( ) ) ) ;
26+ ( ) => InMemoryTransport . Create ( LoggerFactory , Array . Empty < Type > ( ) ) ) ;
2827
2928 Assert . Throws < ArgumentNullException > ( "toolTypes" ,
30- ( ) => InMemoryTransport . Create ( NullLoggerFactory . Instance , null ! ) ) ;
29+ ( ) => InMemoryTransport . Create ( LoggerFactory , null ! ) ) ;
3130 }
3231
3332 [ Fact ]
3433 public async Task ConnectAsync_Should_Set_Connected_State ( )
3534 {
3635 // Arrange
37- var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
36+ var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
3837
3938 // Act
4039 var clientTransport = ( IClientTransport ) transport ;
@@ -50,7 +49,7 @@ public async Task ConnectAsync_Should_Set_Connected_State()
5049 public async Task StartListeningAsync_Should_Set_Connected_State ( )
5150 {
5251 // Arrange
53- await using var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
52+ await using var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
5453
5554 // Act
5655 var serverTransport = ( IServerTransport ) transport ;
@@ -67,7 +66,7 @@ public async Task StartListeningAsync_Should_Set_Connected_State()
6766 public async Task SendMessageAsync_Should_Preserve_Characters ( string messageText )
6867 {
6968 // Arrange
70- var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
69+ var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
7170
7271 IServerTransport serverTransport = transport ;
7372 await serverTransport . StartListeningAsync ( TestContext . Current . CancellationToken ) ;
@@ -103,7 +102,7 @@ public async Task SendMessageAsync_Should_Preserve_Characters(string messageText
103102 public async Task SendMessageAsync_Throws_Exception_If_Not_Connected ( )
104103 {
105104 // Arrange
106- await using var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
105+ await using var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
107106
108107 var message = new JsonRpcRequest { Method = "test" } ;
109108
@@ -116,7 +115,7 @@ await Assert.ThrowsAsync<McpTransportException>(
116115 public async Task DisposeAsync_Should_Dispose_Resources ( )
117116 {
118117 // Arrange
119- var transport = InMemoryTransport . Create ( NullLoggerFactory . Instance , _toolTypes ) ;
118+ var transport = InMemoryTransport . Create ( LoggerFactory , _toolTypes ) ;
120119 IServerTransport serverTransport = transport ;
121120 await serverTransport . StartListeningAsync ( TestContext . Current . CancellationToken ) ;
122121
@@ -127,10 +126,10 @@ public async Task DisposeAsync_Should_Dispose_Resources()
127126 Assert . False ( transport . IsConnected ) ;
128127 }
129128
130- [ McpToolType ]
129+ [ McpServerToolType ]
131130 private class TestTool
132131 {
133- [ McpTool ]
132+ [ McpServerTool ]
134133 public string Echo ( string message ) => message ;
135134 }
136135}
0 commit comments