using Health.Application.AI;
using Health.Domain.Entities;
using Health.Domain.Enums;

namespace Health.Tests;

public sealed class DietCommentaryTests
{
    [Fact]
    public void FoodDescription_ContainsOnlyStructuredFoodData()
    {
        var result = DietCommentaryPolicy.BuildFoodDescription(
        [
            new DietCommentaryFood("番茄炒蛋", "半盘", 220),
            new DietCommentaryFood("米饭", "一碗", 260),
        ]);

        Assert.Equal("番茄炒蛋（半盘，220千卡）、米饭（一碗，260千卡）", result);
        Assert.DoesNotContain("请结合", result);
    }

    [Fact]
    public void LegacyArtifact_RequiresEveryUserMessageToUseInternalPrefix()
    {
        var artifact = new Conversation
        {
            Messages =
            [
                new ConversationMessage
                {
                    Role = MessageRole.User,
                    Content = DietCommentaryPolicy.LegacyPromptPrefix + "食物为：米饭",
                },
                new ConversationMessage
                {
                    Role = MessageRole.Assistant,
                    Content = "注意搭配蔬菜",
                },
            ],
        };
        var normal = new Conversation
        {
            Messages =
            [
                new ConversationMessage
                {
                    Role = MessageRole.User,
                    Content = "我想了解今天的饮食记录",
                },
            ],
        };

        Assert.True(DietCommentaryPolicy.IsLegacyArtifact(artifact.Messages));
        Assert.False(DietCommentaryPolicy.IsLegacyArtifact(normal.Messages));
    }
}
