add tests
All checks were successful
SonarQube / Build and analyze (push) Successful in 3m54s
Unit Tests / Run Tests (push) Successful in 2m23s

This commit is contained in:
Leonid Pershin
2025-10-20 15:11:42 +03:00
parent f8fd16edb2
commit 1c910d7b7f
8 changed files with 549 additions and 154 deletions

View File

@@ -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);
}
}