using SqlSugar;
using System;

namespace Model.Entity
{
    /// <summary>
    /// 测试报告记录：每次 ExecuteSteps / ExecuteErrorSteps 中每个步骤的执行结果。
    /// 同一次运行的所有步骤共享同一个 TestRoundId。
    /// </summary>
    public class TestReportEntity : BaseEntity
    {
        /// <summary>同一次运行的统一标识（StepRunning.TestRoundID）</summary>
        [SugarColumn(ColumnName = "TestRoundId", ColumnDescription = "运行轮次标识")]
        public Guid TestRoundId { get; set; }

        /// <summary>作用域/台架名称</summary>
        [SugarColumn(ColumnName = "Scope", ColumnDescription = "台架名称")]
        public string Scope { get; set; } = string.Empty;
        /// <summary>测试项名称（当前ACP文件路径）</summary>
        [SugarColumn(ColumnName = "FileName", ColumnDescription = "测试项名称")]
        public string FileName { get; set; } = string.Empty;

        /// <summary>步骤序号</summary>
        [SugarColumn(ColumnName = "StepIndex")]
        public int StepIndex { get; set; }

        /// <summary>步骤名称</summary>
        [SugarColumn(ColumnName = "StepName", Length = 200)]
        public string StepName { get; set; } = string.Empty;

        /// <summary>步骤类型（普通步骤/循环开始/循环结束）</summary>
        [SugarColumn(ColumnName = "StepType", Length = 50)]
        public string StepType { get; set; } = string.Empty;

        /// <summary>执行的方法名称</summary>
        [SugarColumn(ColumnName = "MethodName", Length = 200, IsNullable = true)]
        public string? MethodName { get; set; }

        /// <summary>方法的完整类型名（实际方法所属类）</summary>
        [SugarColumn(ColumnName = "MethodFullName", Length = 500, IsNullable = true)]
        public string? MethodFullName { get; set; }

        /// <summary>执行结果（成功/失败/未执行/跳过）</summary>
        [SugarColumn(ColumnName = "Result", Length = 20)]
        public string Result { get; set; } = string.Empty;

        /// <summary>执行耗时（毫秒）</summary>
        [SugarColumn(ColumnName = "RunTimeMs", IsNullable = true)]
        public int? RunTimeMs { get; set; }

        /// <summary>输出值（如果有）</summary>
        [SugarColumn(ColumnName = "OutputValue", Length = 500, IsNullable = true)]
        public string? OutputValue { get; set; }

        /// <summary>子程序嵌套深度（0=主程序）</summary>
        [SugarColumn(ColumnName = "Depth")]
        public int Depth { get; set; }

        /// <summary>是否异常流程步骤</summary>
        [SugarColumn(ColumnName = "IsErrorStep")]
        public bool IsErrorStep { get; set; }

        /// <summary>循环剩余次数（仅循环步骤有值）</summary>
        [SugarColumn(ColumnName = "LoopRemaining", IsNullable = true)]
        public int? LoopRemaining { get; set; }
    }
}
