Skip to content

Commit b9964e2

Browse files
committed
Add tests for enum serialization
1 parent a57efa5 commit b9964e2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/ModelContextProtocol.Tests/Protocol/ProtocolTypeTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ModelContextProtocol.Protocol.Types;
2+
using ModelContextProtocol.Utils.Json;
23
using System.Text.Json;
34

45
namespace ModelContextProtocol.Tests.Protocol;
@@ -51,4 +52,30 @@ public static void ToolInputSchema_AcceptsValidSchemaDocuments(string validSchem
5152

5253
Assert.True(JsonElement.DeepEquals(document.RootElement, tool.InputSchema));
5354
}
55+
56+
[Theory]
57+
[InlineData(Role.User, "\"user\"")]
58+
[InlineData(Role.Assistant, "\"assistant\"")]
59+
public static void SerializeRole_Should_Be_Lower_Case(Role role, string expectedValue)
60+
{
61+
var actualValue = JsonSerializer.Serialize(role, McpJsonUtilities.DefaultOptions);
62+
63+
Assert.Equal(expectedValue, actualValue);
64+
}
65+
66+
[Theory]
67+
[InlineData(LoggingLevel.Debug, "\"debug\"")]
68+
[InlineData(LoggingLevel.Info, "\"info\"")]
69+
[InlineData(LoggingLevel.Notice, "\"notice\"")]
70+
[InlineData(LoggingLevel.Warning, "\"warning\"")]
71+
[InlineData(LoggingLevel.Error, "\"error\"")]
72+
[InlineData(LoggingLevel.Critical, "\"critical\"")]
73+
[InlineData(LoggingLevel.Alert, "\"alert\"")]
74+
[InlineData(LoggingLevel.Emergency, "\"emergency\"")]
75+
public static void SerializeLoggingLevel_Should_Be_Lower_Case(LoggingLevel level, string expectedValue)
76+
{
77+
var actualValue = JsonSerializer.Serialize(level, McpJsonUtilities.DefaultOptions);
78+
79+
Assert.Equal(expectedValue, actualValue);
80+
}
5481
}

0 commit comments

Comments
 (0)