File tree Expand file tree Collapse file tree
tests/ModelContextProtocol.Tests/Server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using ModelContextProtocol . Server ;
2+ using System . Reflection ;
3+
4+ namespace ModelContextProtocol . Tests . Server ;
5+
6+ public class DelegatingMcpServerPromptTests
7+ {
8+ [ Fact ]
9+ public void OverridesAllVirtualAndAbstractMembers ( )
10+ {
11+ MethodInfo [ ] baseMethods = typeof ( McpServerPrompt ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
12+ . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerPrompt ) )
13+ . ToArray ( ) ;
14+
15+ Assert . NotEmpty ( baseMethods ) ;
16+
17+ foreach ( MethodInfo baseMethod in baseMethods )
18+ {
19+ MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerPrompt ) . GetMethod (
20+ baseMethod . Name ,
21+ BindingFlags . Public | BindingFlags . Instance ,
22+ baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
23+
24+ Assert . True (
25+ overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerPrompt ) ,
26+ $ "DelegatingMcpServerPrompt does not override { baseMethod . Name } from McpServerPrompt.") ;
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ using ModelContextProtocol . Server ;
2+ using System . Reflection ;
3+
4+ namespace ModelContextProtocol . Tests . Server ;
5+
6+ public class DelegatingMcpServerResourceTests
7+ {
8+ [ Fact ]
9+ public void OverridesAllVirtualAndAbstractMembers ( )
10+ {
11+ MethodInfo [ ] baseMethods = typeof ( McpServerResource ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
12+ . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerResource ) )
13+ . ToArray ( ) ;
14+
15+ Assert . NotEmpty ( baseMethods ) ;
16+
17+ foreach ( MethodInfo baseMethod in baseMethods )
18+ {
19+ MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerResource ) . GetMethod (
20+ baseMethod . Name ,
21+ BindingFlags . Public | BindingFlags . Instance ,
22+ baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
23+
24+ Assert . True (
25+ overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerResource ) ,
26+ $ "DelegatingMcpServerResource does not override { baseMethod . Name } from McpServerResource.") ;
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ using ModelContextProtocol . Server ;
2+ using System . Reflection ;
3+
4+ namespace ModelContextProtocol . Tests . Server ;
5+
6+ public class DelegatingMcpServerToolTests
7+ {
8+ [ Fact ]
9+ public void OverridesAllVirtualAndAbstractMembers ( )
10+ {
11+ MethodInfo [ ] baseMethods = typeof ( McpServerTool ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
12+ . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerTool ) )
13+ . ToArray ( ) ;
14+
15+ Assert . NotEmpty ( baseMethods ) ;
16+
17+ foreach ( MethodInfo baseMethod in baseMethods )
18+ {
19+ MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerTool ) . GetMethod (
20+ baseMethod . Name ,
21+ BindingFlags . Public | BindingFlags . Instance ,
22+ baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
23+
24+ Assert . True (
25+ overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerTool ) ,
26+ $ "DelegatingMcpServerTool does not override { baseMethod . Name } from McpServerTool.") ;
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -547,26 +547,4 @@ public void SupportsPromptWithoutIcons()
547547
548548 Assert . Null ( prompt . ProtocolPrompt . Icons ) ;
549549 }
550-
551- [ Fact ]
552- public void DelegatingMcpServerPrompt_OverridesAllVirtualAndAbstractMembers ( )
553- {
554- MethodInfo [ ] baseMethods = typeof ( McpServerPrompt ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
555- . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerPrompt ) )
556- . ToArray ( ) ;
557-
558- Assert . NotEmpty ( baseMethods ) ;
559-
560- foreach ( MethodInfo baseMethod in baseMethods )
561- {
562- MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerPrompt ) . GetMethod (
563- baseMethod . Name ,
564- BindingFlags . Public | BindingFlags . Instance ,
565- baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
566-
567- Assert . True (
568- overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerPrompt ) ,
569- $ "DelegatingMcpServerPrompt does not override { baseMethod . Name } from McpServerPrompt.") ;
570- }
571- }
572550}
Original file line number Diff line number Diff line change @@ -734,28 +734,6 @@ public void SupportsResourceWithoutIcons()
734734 Assert . Null ( resource . ProtocolResourceTemplate . Icons ) ;
735735 }
736736
737- [ Fact ]
738- public void DelegatingMcpServerResource_OverridesAllVirtualAndAbstractMembers ( )
739- {
740- MethodInfo [ ] baseMethods = typeof ( McpServerResource ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
741- . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerResource ) )
742- . ToArray ( ) ;
743-
744- Assert . NotEmpty ( baseMethods ) ;
745-
746- foreach ( MethodInfo baseMethod in baseMethods )
747- {
748- MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerResource ) . GetMethod (
749- baseMethod . Name ,
750- BindingFlags . Public | BindingFlags . Instance ,
751- baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
752-
753- Assert . True (
754- overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerResource ) ,
755- $ "DelegatingMcpServerResource does not override { baseMethod . Name } from McpServerResource.") ;
756- }
757- }
758-
759737 [ JsonSourceGenerationOptions ( PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ) ]
760738 [ JsonSerializable ( typeof ( DisposableResourceType ) ) ]
761739 [ JsonSerializable ( typeof ( List < AIContent > ) ) ]
Original file line number Diff line number Diff line change @@ -918,28 +918,6 @@ private static string SyncTool()
918918 [ Description ( "Tool without return description." ) ]
919919 private static string ToolWithoutReturnDescription ( ) => "result" ;
920920
921- [ Fact ]
922- public void DelegatingMcpServerTool_OverridesAllVirtualAndAbstractMembers ( )
923- {
924- MethodInfo [ ] baseMethods = typeof ( McpServerTool ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance )
925- . Where ( m => ( m . IsVirtual || m . IsAbstract ) && m . DeclaringType == typeof ( McpServerTool ) )
926- . ToArray ( ) ;
927-
928- Assert . NotEmpty ( baseMethods ) ;
929-
930- foreach ( MethodInfo baseMethod in baseMethods )
931- {
932- MethodInfo ? overriddenMethod = typeof ( DelegatingMcpServerTool ) . GetMethod (
933- baseMethod . Name ,
934- BindingFlags . Public | BindingFlags . Instance ,
935- baseMethod . GetParameters ( ) . Select ( p => p . ParameterType ) . ToArray ( ) ) ;
936-
937- Assert . True (
938- overriddenMethod is not null && overriddenMethod . DeclaringType == typeof ( DelegatingMcpServerTool ) ,
939- $ "DelegatingMcpServerTool does not override { baseMethod . Name } from McpServerTool.") ;
940- }
941- }
942-
943921 [ JsonSourceGenerationOptions ( PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ) ]
944922 [ JsonSerializable ( typeof ( JsonNode ) ) ]
945923 [ JsonSerializable ( typeof ( DisposableToolType ) ) ]
You can’t perform that action at this time.
0 commit comments