File tree Expand file tree Collapse file tree
tests/ModelContextProtocol.Tests/Server Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -547,4 +547,26 @@ 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+ }
550572}
Original file line number Diff line number Diff line change @@ -734,6 +734,28 @@ 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+
737759 [ JsonSourceGenerationOptions ( PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ) ]
738760 [ JsonSerializable ( typeof ( DisposableResourceType ) ) ]
739761 [ JsonSerializable ( typeof ( List < AIContent > ) ) ]
Original file line number Diff line number Diff line change @@ -918,6 +918,28 @@ 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+
921943 [ JsonSourceGenerationOptions ( PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ) ]
922944 [ JsonSerializable ( typeof ( JsonNode ) ) ]
923945 [ JsonSerializable ( typeof ( DisposableToolType ) ) ]
You can’t perform that action at this time.
0 commit comments