add tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Text.Json;
|
||||
using ChatBot.Models.Dto;
|
||||
using FluentAssertions;
|
||||
using OllamaSharp.Models.Chat;
|
||||
@@ -360,4 +361,24 @@ public class ChatMessageTests
|
||||
message.Content.Should().Be(content);
|
||||
message.Role.Should().Be(role);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_RoundTrip_ShouldPreserveProperties()
|
||||
{
|
||||
// Arrange
|
||||
var original = new ChatMessage { Content = "Hello DTO", Role = ChatRole.Assistant };
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = false,
|
||||
};
|
||||
|
||||
// Act
|
||||
var json = JsonSerializer.Serialize(original, options);
|
||||
var deserialized = JsonSerializer.Deserialize<ChatMessage>(json, options)!;
|
||||
|
||||
// Assert
|
||||
deserialized.Content.Should().Be(original.Content);
|
||||
deserialized.Role.Should().Be(original.Role);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user