You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
220 lines
5.6 KiB
220 lines
5.6 KiB
using System.ComponentModel.DataAnnotations;
|
|
using CellularManagement.Domain.Entities.Common;
|
|
using CellularManagement.Domain.Models;
|
|
using CellularManagement.Domain.ValueObjects;
|
|
|
|
namespace CellularManagement.Domain.Entities.Device;
|
|
|
|
/// <summary>
|
|
/// 用例实体
|
|
/// </summary>
|
|
public class TestCase : AuditableEntity
|
|
{
|
|
private TestCase() { }
|
|
|
|
/// <summary>
|
|
/// 用例编码
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string Code { get; private set; } = null!;
|
|
|
|
/// <summary>
|
|
/// 用例名称
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string Name { get; private set; } = null!;
|
|
|
|
/// <summary>
|
|
/// 用户数(1-5,作为父级参数)
|
|
/// </summary>
|
|
public int UserCount { get; private set; } = 1;
|
|
|
|
/// <summary>
|
|
/// 用户信息列表(JSON格式存储)
|
|
/// 格式示例:
|
|
/// [
|
|
/// {
|
|
/// "UserId": 1,
|
|
/// "IMSI1": "460001234567890",
|
|
/// "IMSI2": "460001234567891"
|
|
/// },
|
|
/// {
|
|
/// "UserId": 2,
|
|
/// "IMSI1": "460001234567892",
|
|
/// "IMSI2": "460001234567893"
|
|
/// }
|
|
/// ]
|
|
/// </summary>
|
|
[MaxLength(4000)]
|
|
public string? UserInfoList { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 时延阈值数
|
|
/// </summary>
|
|
public int LatencyThresholdCount { get; private set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 时延阈值列表(JSON格式存储)
|
|
/// </summary>
|
|
[MaxLength(2000)]
|
|
public string? LatencyThresholdList { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 吞吐量阈值数
|
|
/// </summary>
|
|
public int ThroughputThresholdCount { get; private set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 吞吐量阈值列表(JSON格式存储)
|
|
/// </summary>
|
|
[MaxLength(2000)]
|
|
public string? ThroughputThresholdList { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 用例说明
|
|
/// </summary>
|
|
[MaxLength(1000)]
|
|
public string? Description { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 用例版本
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(20)]
|
|
public string Version { get; private set; } = null!;
|
|
|
|
/// <summary>
|
|
/// 版本更新信息
|
|
/// </summary>
|
|
[MaxLength(500)]
|
|
public string? VersionUpdateInfo { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 是否禁用
|
|
/// </summary>
|
|
public bool IsDisabled { get; private set; } = false;
|
|
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
[MaxLength(1000)]
|
|
public string? Remarks { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 创建用例
|
|
/// </summary>
|
|
public static TestCase Create(
|
|
string code,
|
|
string name,
|
|
string version,
|
|
string createdBy,
|
|
int userCount = 1,
|
|
string? userInfoList = null,
|
|
int latencyThresholdCount = 0,
|
|
string? latencyThresholdList = null,
|
|
int throughputThresholdCount = 0,
|
|
string? throughputThresholdList = null,
|
|
string? description = null,
|
|
string? versionUpdateInfo = null,
|
|
bool isDisabled = false,
|
|
string? remarks = null)
|
|
{
|
|
var testCase = new TestCase
|
|
{
|
|
Id = Guid.NewGuid().ToString(),
|
|
Code = code,
|
|
Name = name,
|
|
Version = version,
|
|
UserCount = userCount,
|
|
UserInfoList = userInfoList,
|
|
LatencyThresholdCount = latencyThresholdCount,
|
|
LatencyThresholdList = latencyThresholdList,
|
|
ThroughputThresholdCount = throughputThresholdCount,
|
|
ThroughputThresholdList = throughputThresholdList,
|
|
Description = description,
|
|
VersionUpdateInfo = versionUpdateInfo,
|
|
IsDisabled = isDisabled,
|
|
Remarks = remarks,
|
|
CreatedAt = DateTime.UtcNow,
|
|
UpdatedAt = DateTime.UtcNow,
|
|
CreatedBy = createdBy,
|
|
UpdatedBy = createdBy
|
|
};
|
|
|
|
return testCase;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新用例
|
|
/// </summary>
|
|
public void Update(
|
|
string code,
|
|
string name,
|
|
string version,
|
|
string updatedBy,
|
|
int userCount = 1,
|
|
string? userInfoList = null,
|
|
int latencyThresholdCount = 0,
|
|
string? latencyThresholdList = null,
|
|
int throughputThresholdCount = 0,
|
|
string? throughputThresholdList = null,
|
|
string? description = null,
|
|
string? versionUpdateInfo = null,
|
|
bool isDisabled = false,
|
|
string? remarks = null)
|
|
{
|
|
Code = code;
|
|
Name = name;
|
|
Version = version;
|
|
UserCount = userCount;
|
|
UserInfoList = userInfoList;
|
|
LatencyThresholdCount = latencyThresholdCount;
|
|
LatencyThresholdList = latencyThresholdList;
|
|
ThroughputThresholdCount = throughputThresholdCount;
|
|
ThroughputThresholdList = throughputThresholdList;
|
|
Description = description;
|
|
VersionUpdateInfo = versionUpdateInfo;
|
|
IsDisabled = isDisabled;
|
|
Remarks = remarks;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
UpdatedBy = updatedBy;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 启用用例
|
|
/// </summary>
|
|
public void Enable()
|
|
{
|
|
IsDisabled = false;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 禁用用例
|
|
/// </summary>
|
|
public void Disable()
|
|
{
|
|
IsDisabled = true;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 软删除用例
|
|
/// </summary>
|
|
public void SoftDelete()
|
|
{
|
|
IsDeleted = true;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 恢复用例
|
|
/// </summary>
|
|
public void Restore()
|
|
{
|
|
IsDeleted = false;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
}
|