Browse Source
- 创建 ITestCaseEdgeRepository 接口,提供测试用例连线完整的数据访问能力 - 创建 ITestCaseNodeRepository 接口,提供测试用例节点完整的数据访问能力 - 实现 TestCaseEdgeRepository 和 TestCaseNodeRepository 具体实现类 - 支持基本的 CRUD 操作和特定的业务查询功能 - 集成 CQRS 模式,使用 ICommandRepository 和 IQueryRepository - 在依赖注入容器中注册新的仓储服务 - 遵循 DDD 设计原则,与现有仓储架构保持一致 新增功能: - 测试用例连线的批量删除、按源/目标节点查询 - 测试用例节点的序号管理、按步骤配置查询 - 完整的验证和统计操作方法release/web-ui-v1.0.0
9 changed files with 1010 additions and 0 deletions
@ -0,0 +1,101 @@ |
|||||
|
using X1.Domain.Entities.TestCase; |
||||
|
using X1.Domain.Repositories.Base; |
||||
|
|
||||
|
namespace X1.Domain.Repositories.TestCase; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 测试用例连线仓储接口
|
||||
|
/// </summary>
|
||||
|
public interface ITestCaseEdgeRepository : IBaseRepository<TestCaseEdge> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 添加测试用例连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseEdge">测试用例连线</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>添加的测试用例连线</returns>
|
||||
|
Task<TestCaseEdge> AddTestCaseEdgeAsync(TestCaseEdge testCaseEdge, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新测试用例连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseEdge">测试用例连线</param>
|
||||
|
void UpdateTestCaseEdge(TestCaseEdge testCaseEdge); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除测试用例连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">连线ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
Task DeleteTestCaseEdgeAsync(string id, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID删除所有连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
Task DeleteByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取所有测试用例连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线列表</returns>
|
||||
|
Task<IList<TestCaseEdge>> GetAllTestCaseEdgesAsync(CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID获取测试用例连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">连线ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线</returns>
|
||||
|
Task<TestCaseEdge?> GetTestCaseEdgeByIdAsync(string id, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线列表</returns>
|
||||
|
Task<IEnumerable<TestCaseEdge>> GetByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据源节点ID获取连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="sourceNodeId">源节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线列表</returns>
|
||||
|
Task<IEnumerable<TestCaseEdge>> GetBySourceNodeIdAsync(string sourceNodeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据目标节点ID获取连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="targetNodeId">目标节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线列表</returns>
|
||||
|
Task<IEnumerable<TestCaseEdge>> GetByTargetNodeIdAsync(string targetNodeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据连线ID获取连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="edgeId">连线ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例连线</returns>
|
||||
|
Task<TestCaseEdge?> GetByEdgeIdAsync(string edgeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查连线ID是否存在
|
||||
|
/// </summary>
|
||||
|
/// <param name="edgeId">连线ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>是否存在</returns>
|
||||
|
Task<bool> EdgeIdExistsAsync(string edgeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中是否存在连线
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>是否存在</returns>
|
||||
|
Task<bool> ExistsByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -0,0 +1,127 @@ |
|||||
|
using X1.Domain.Entities.TestCase; |
||||
|
using X1.Domain.Repositories.Base; |
||||
|
|
||||
|
namespace X1.Domain.Repositories.TestCase; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 测试用例节点仓储接口
|
||||
|
/// </summary>
|
||||
|
public interface ITestCaseNodeRepository : IBaseRepository<TestCaseNode> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 添加测试用例节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseNode">测试用例节点</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>添加的测试用例节点</returns>
|
||||
|
Task<TestCaseNode> AddTestCaseNodeAsync(TestCaseNode testCaseNode, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新测试用例节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseNode">测试用例节点</param>
|
||||
|
void UpdateTestCaseNode(TestCaseNode testCaseNode); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除测试用例节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
Task DeleteTestCaseNodeAsync(string id, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID删除所有节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
Task DeleteByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取所有测试用例节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点列表</returns>
|
||||
|
Task<IList<TestCaseNode>> GetAllTestCaseNodesAsync(CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID获取测试用例节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点</returns>
|
||||
|
Task<TestCaseNode?> GetTestCaseNodeByIdAsync(string id, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点列表</returns>
|
||||
|
Task<IEnumerable<TestCaseNode>> GetByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有节点(按序号排序)
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点列表</returns>
|
||||
|
Task<IEnumerable<TestCaseNode>> GetByTestCaseIdOrderedAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据节点ID获取节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="nodeId">节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点</returns>
|
||||
|
Task<TestCaseNode?> GetByNodeIdAsync(string nodeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据步骤配置ID获取节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="stepId">步骤配置ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点列表</returns>
|
||||
|
Task<IEnumerable<TestCaseNode>> GetByStepIdAsync(string stepId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID和序号获取节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="sequenceNumber">序号</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>测试用例节点</returns>
|
||||
|
Task<TestCaseNode?> GetByTestCaseIdAndSequenceAsync(string testCaseId, int sequenceNumber, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查节点ID是否存在
|
||||
|
/// </summary>
|
||||
|
/// <param name="nodeId">节点ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>是否存在</returns>
|
||||
|
Task<bool> NodeIdExistsAsync(string nodeId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中是否存在节点
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>是否存在</returns>
|
||||
|
Task<bool> ExistsByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中序号是否存在
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="sequenceNumber">序号</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>是否存在</returns>
|
||||
|
Task<bool> SequenceExistsAsync(string testCaseId, int sequenceNumber, CancellationToken cancellationToken = default); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取测试用例中最大的序号
|
||||
|
/// </summary>
|
||||
|
/// <param name="testCaseId">测试用例ID</param>
|
||||
|
/// <param name="cancellationToken">取消令牌</param>
|
||||
|
/// <returns>最大序号</returns>
|
||||
|
Task<int> GetMaxSequenceNumberAsync(string testCaseId, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -0,0 +1,137 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Linq; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using X1.Infrastructure.Repositories.Base; |
||||
|
using X1.Domain.Repositories.Base; |
||||
|
using X1.Domain.Entities.TestCase; |
||||
|
using X1.Domain.Repositories.TestCase; |
||||
|
|
||||
|
namespace X1.Infrastructure.Repositories.TestCase; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 测试用例连线仓储实现
|
||||
|
/// </summary>
|
||||
|
public class TestCaseEdgeRepository : BaseRepository<TestCaseEdge>, ITestCaseEdgeRepository |
||||
|
{ |
||||
|
private readonly ILogger<TestCaseEdgeRepository> _logger; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 初始化仓储
|
||||
|
/// </summary>
|
||||
|
public TestCaseEdgeRepository( |
||||
|
ICommandRepository<TestCaseEdge> commandRepository, |
||||
|
IQueryRepository<TestCaseEdge> queryRepository, |
||||
|
ILogger<TestCaseEdgeRepository> logger) |
||||
|
: base(commandRepository, queryRepository, logger) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 添加测试用例连线
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseEdge> AddTestCaseEdgeAsync(TestCaseEdge testCaseEdge, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var result = await CommandRepository.AddAsync(testCaseEdge, cancellationToken); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新测试用例连线
|
||||
|
/// </summary>
|
||||
|
public void UpdateTestCaseEdge(TestCaseEdge testCaseEdge) |
||||
|
{ |
||||
|
CommandRepository.Update(testCaseEdge); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除测试用例连线
|
||||
|
/// </summary>
|
||||
|
public async Task DeleteTestCaseEdgeAsync(string id, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
await CommandRepository.DeleteByIdAsync(id, cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID删除所有连线
|
||||
|
/// </summary>
|
||||
|
public async Task DeleteByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var edges = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
foreach (var edge in edges) |
||||
|
{ |
||||
|
await CommandRepository.DeleteByIdAsync(edge.Id, cancellationToken); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取所有测试用例连线
|
||||
|
/// </summary>
|
||||
|
public async Task<IList<TestCaseEdge>> GetAllTestCaseEdgesAsync(CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var edges = await QueryRepository.GetAllAsync(cancellationToken: cancellationToken); |
||||
|
return edges.ToList(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID获取测试用例连线
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseEdge?> GetTestCaseEdgeByIdAsync(string id, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.GetByIdAsync(id, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有连线
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseEdge>> GetByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var edges = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
return edges.OrderBy(x => x.EdgeId); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据源节点ID获取连线
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseEdge>> GetBySourceNodeIdAsync(string sourceNodeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var edges = await QueryRepository.FindAsync(x => x.SourceNodeId == sourceNodeId, cancellationToken: cancellationToken); |
||||
|
return edges.OrderBy(x => x.EdgeId); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据目标节点ID获取连线
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseEdge>> GetByTargetNodeIdAsync(string targetNodeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var edges = await QueryRepository.FindAsync(x => x.TargetNodeId == targetNodeId, cancellationToken: cancellationToken); |
||||
|
return edges.OrderBy(x => x.EdgeId); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据连线ID获取连线
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseEdge?> GetByEdgeIdAsync(string edgeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.FirstOrDefaultAsync(x => x.EdgeId == edgeId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查连线ID是否存在
|
||||
|
/// </summary>
|
||||
|
public async Task<bool> EdgeIdExistsAsync(string edgeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.AnyAsync(x => x.EdgeId == edgeId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中是否存在连线
|
||||
|
/// </summary>
|
||||
|
public async Task<bool> ExistsByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.AnyAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,162 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Linq; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using X1.Infrastructure.Repositories.Base; |
||||
|
using X1.Domain.Repositories.Base; |
||||
|
using X1.Domain.Entities.TestCase; |
||||
|
using X1.Domain.Repositories.TestCase; |
||||
|
|
||||
|
namespace X1.Infrastructure.Repositories.TestCase; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 测试用例节点仓储实现
|
||||
|
/// </summary>
|
||||
|
public class TestCaseNodeRepository : BaseRepository<TestCaseNode>, ITestCaseNodeRepository |
||||
|
{ |
||||
|
private readonly ILogger<TestCaseNodeRepository> _logger; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 初始化仓储
|
||||
|
/// </summary>
|
||||
|
public TestCaseNodeRepository( |
||||
|
ICommandRepository<TestCaseNode> commandRepository, |
||||
|
IQueryRepository<TestCaseNode> queryRepository, |
||||
|
ILogger<TestCaseNodeRepository> logger) |
||||
|
: base(commandRepository, queryRepository, logger) |
||||
|
{ |
||||
|
_logger = logger; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 添加测试用例节点
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseNode> AddTestCaseNodeAsync(TestCaseNode testCaseNode, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var result = await CommandRepository.AddAsync(testCaseNode, cancellationToken); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新测试用例节点
|
||||
|
/// </summary>
|
||||
|
public void UpdateTestCaseNode(TestCaseNode testCaseNode) |
||||
|
{ |
||||
|
CommandRepository.Update(testCaseNode); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除测试用例节点
|
||||
|
/// </summary>
|
||||
|
public async Task DeleteTestCaseNodeAsync(string id, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
await CommandRepository.DeleteByIdAsync(id, cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID删除所有节点
|
||||
|
/// </summary>
|
||||
|
public async Task DeleteByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
foreach (var node in nodes) |
||||
|
{ |
||||
|
await CommandRepository.DeleteByIdAsync(node.Id, cancellationToken); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取所有测试用例节点
|
||||
|
/// </summary>
|
||||
|
public async Task<IList<TestCaseNode>> GetAllTestCaseNodesAsync(CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.GetAllAsync(cancellationToken: cancellationToken); |
||||
|
return nodes.ToList(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据ID获取测试用例节点
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseNode?> GetTestCaseNodeByIdAsync(string id, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.GetByIdAsync(id, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有节点
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseNode>> GetByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
return nodes.OrderBy(x => x.NodeId); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID获取所有节点(按序号排序)
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseNode>> GetByTestCaseIdOrderedAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
return nodes.OrderBy(x => x.SequenceNumber); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据节点ID获取节点
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseNode?> GetByNodeIdAsync(string nodeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.FirstOrDefaultAsync(x => x.NodeId == nodeId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据步骤配置ID获取节点
|
||||
|
/// </summary>
|
||||
|
public async Task<IEnumerable<TestCaseNode>> GetByStepIdAsync(string stepId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.FindAsync(x => x.StepId == stepId, cancellationToken: cancellationToken); |
||||
|
return nodes.OrderBy(x => x.SequenceNumber); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 根据测试用例ID和序号获取节点
|
||||
|
/// </summary>
|
||||
|
public async Task<TestCaseNode?> GetByTestCaseIdAndSequenceAsync(string testCaseId, int sequenceNumber, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.FirstOrDefaultAsync(x => x.TestCaseId == testCaseId && x.SequenceNumber == sequenceNumber, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查节点ID是否存在
|
||||
|
/// </summary>
|
||||
|
public async Task<bool> NodeIdExistsAsync(string nodeId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.AnyAsync(x => x.NodeId == nodeId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中是否存在节点
|
||||
|
/// </summary>
|
||||
|
public async Task<bool> ExistsByTestCaseIdAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.AnyAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 检查测试用例中序号是否存在
|
||||
|
/// </summary>
|
||||
|
public async Task<bool> SequenceExistsAsync(string testCaseId, int sequenceNumber, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await QueryRepository.AnyAsync(x => x.TestCaseId == testCaseId && x.SequenceNumber == sequenceNumber, cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取测试用例中最大的序号
|
||||
|
/// </summary>
|
||||
|
public async Task<int> GetMaxSequenceNumberAsync(string testCaseId, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var nodes = await QueryRepository.FindAsync(x => x.TestCaseId == testCaseId, cancellationToken: cancellationToken); |
||||
|
return nodes.Any() ? nodes.Max(x => x.SequenceNumber) : 0; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue