NavisworksTransport/UnitTests/Integration/PathAnalysisAutomationTests.cs
tian 8e5d9e845f feat: 集成测试补 T11-T15(P0+P1+P2 全部完成,24/24 通过)
- T11 路径编辑(PathEditingAutomationTests):删除点/更新位置/正交化/去环
- T12 路径导出(ExportImportRoundTripAutomationTests):XML/JSON 导出→导入回环
- T13 播放控制(AnimationPlaybackControlAutomationTests):pause 验证帧停止/resume 前进
- T14 批量队列(BatchQueueAutomationTests):队列添加/计数递增
- T15 路径分析(PathAnalysisAutomationTests):评分结构验证
- 服务端新增 5 端点:export-route-file/edit-route/animation-playback-control/batch-queue-add/analyze-path
- 产品 bug 修复:PathDatabase.CollisionResults 表已废弃→GetCollisionCount 改查 CollisionReports、
  SaveCollisions 异常保护;路径编辑真删点走 PathRoute.RemovePoint(RemovePathPoint 仅 3D 标记)

验证:集成测试 24/24 通过,完整集 74.6s(15fps/5s 动画)
2026-08-04 18:39:16 +08:00

53 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
namespace NavisworksTransport.UnitTests.Integration
{
/// <summary>
/// 路径分析集成测试(覆盖计划 T15
///
/// 验证路径分析链路PathAnalysisService.AnalyzePath
/// - 分析成功并返回与路径关联的评分结果
/// - 评分结构完整(安全/效率/综合分、转弯难度、曲折度等)
/// - 策略参数正确回传
/// </summary>
[TestClass]
[TestCategory("NavisworksIntegration")]
public class PathAnalysisAutomationTests
{
[TestMethod]
[Timeout(240000)]
public async Task GroundRoute_Analysis_ReturnsValidScores()
{
using (var client = new NavisworksTestAutomationClient())
{
await client.EnsureServiceReadyAsync(TimeSpan.FromSeconds(90)).ConfigureAwait(false);
JObject response = await client.AnalyzePathAsync("自动测试_Ground", "安全优先").ConfigureAwait(false);
Assert.IsTrue(response.Value<bool>("ok"), "路径分析失败: " + (string)response["error"]);
JObject data = (JObject)response["data"];
// 关联路径
Assert.AreEqual("自动测试_Ground", (string)data["routeName"], "分析路径名不匹配");
Assert.IsFalse(string.IsNullOrWhiteSpace((string)data["routeId"]), "分析结果缺少路径 ID");
// 策略回传
Assert.AreEqual("安全优先", (string)data["strategy"], "分析策略不匹配");
// 评分结构(非负)
Assert.IsTrue((int)data["collisionCount"] >= 0, "碰撞数不能为负");
Assert.IsTrue((double)data["safetyScore"] >= 0, "安全评分不能为负");
Assert.IsTrue((double)data["efficiencyScore"] >= 0, "效率评分不能为负");
Assert.IsTrue((double)data["overallScore"] >= 0, "综合评分不能为负");
Assert.IsTrue((double)data["turnDifficultyScore"] >= 0, "转弯难度评分不能为负");
Assert.IsTrue((double)data["tortuosityScore"] >= 0, "曲折度评分不能为负");
Assert.IsTrue((double)data["redundancyScore"] >= 0, "冗余度评分不能为负");
Assert.IsTrue((int)data["hotspotCount"] >= 0, "热点数不能为负");
}
}
}
}