File tree Expand file tree Collapse file tree 5 files changed +54
-1
lines changed
src/Adapters.Mcp.Core/Serialization
test/Adapters.Mcp.Core.Tests Expand file tree Collapse file tree 5 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 194194 <Project Path =" HotChocolate/Adapters/src/Fusion.Adapters.OpenApi/HotChocolate.Fusion.Adapters.OpenApi.csproj" />
195195 </Folder >
196196 <Folder Name =" /HotChocolate/Adapters/test/" >
197+ <Project Path =" HotChocolate/Adapters/test/Adapters.Mcp.Core.Tests/HotChocolate.Adapters.Mcp.Core.Tests.csproj" />
197198 <Project Path =" HotChocolate/Adapters/test/Adapters.Mcp.Packaging.Tests/HotChocolate.Adapters.Mcp.Packaging.Tests.csproj" />
198199 <Project Path =" HotChocolate/Adapters/test/Adapters.Mcp.Tests/HotChocolate.Adapters.Mcp.Tests.csproj" />
199200 <Project Path =" HotChocolate/Adapters/test/Adapters.OpenApi.Packaging.Tests/HotChocolate.Adapters.OpenApi.Packaging.Tests.csproj" />
Original file line number Diff line number Diff line change 1515 </Folder >
1616 <Folder Name =" /test/" />
1717 <Folder Name =" /test/Adapters.Mcp.Tests/" >
18+ <Project Path =" test\Adapters.Mcp.Core.Tests\HotChocolate.Adapters.Mcp.Core.Tests.csproj" />
1819 <Project Path =" test\Adapters.Mcp.Packaging.Tests\HotChocolate.Adapters.Mcp.Packaging.Tests.csproj" />
1920 <Project Path =" test\Adapters.Mcp.Tests\HotChocolate.Adapters.Mcp.Tests.csproj" />
2021 </Folder >
Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ namespace HotChocolate.Adapters.Mcp.Serialization;
66[ JsonSerializable ( typeof ( McpToolSettingsDto ) ) ]
77[ JsonSourceGenerationOptions (
88 PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ,
9- DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull ) ]
9+ DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull ,
10+ AllowOutOfOrderMetadataProperties = true ) ]
1011internal partial class McpSettingsSerializerContext : JsonSerializerContext ;
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <Import Project =" $([MSBuild]::GetPathOfFileAbove('Xunit2.Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />
3+
4+ <PropertyGroup >
5+ <AssemblyName >HotChocolate.Adapters.Mcp.Core.Tests</AssemblyName >
6+ <RootNamespace >HotChocolate.Adapters.Mcp.Core</RootNamespace >
7+ </PropertyGroup >
8+
9+ <ItemGroup >
10+ <ProjectReference Include =" ..\..\src\Adapters.Mcp.Core\HotChocolate.Adapters.Mcp.Core.csproj" />
11+ </ItemGroup >
12+
13+ </Project >
Original file line number Diff line number Diff line change 1+ using System . Text . Json ;
2+ using HotChocolate . Adapters . Mcp . Serialization ;
3+
4+ namespace HotChocolate . Adapters . Mcp . Core . Serialization ;
5+
6+ public sealed class McpPromptSettingsSerializerTests
7+ {
8+ [ Fact ]
9+ public void Parse_WithPolymorphicMessages_ShouldSucceed ( )
10+ {
11+ // arrange
12+ var document =
13+ JsonDocument . Parse (
14+ """
15+ {
16+ "messages": [
17+ {
18+ "role": "user",
19+ "content": {
20+ "text": "Get the person",
21+ "type": "text"
22+ }
23+ }
24+ ]
25+ }
26+ """ ) ;
27+
28+ // act
29+ var settings = McpPromptSettingsSerializer . Parse ( document ) ;
30+
31+ // assert
32+ var message = Assert . Single ( settings . Messages ) ;
33+ Assert . Equal ( "user" , message . Role ) ;
34+ var content = Assert . IsType < McpPromptSettingsTextContentDto > ( message . Content ) ;
35+ Assert . Equal ( "Get the person" , content . Text ) ;
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments