NavisworksTransport/UnitTests/Integration/CollisionReportAssertions.cs
tian 44214baa00 feat: 集成测试补 T05/T06 + 动画加速与多项基础设施修复
测试新增:
- T05 Free 自由路径(FreePathAutomationTests:完整动画 + 逐帧位置=路径点)
- T06 碰撞报告内容断言(CollisionReportAssertions 接入虚拟/真实物体测试)

服务端增强:
- list-model-items 端点(枚举物体:DisplayName/PathId/包围盒中心/祖先链)
- run-virtual-collision-test 支持 frameRate/durationSeconds(测试动画加速:15fps/5s)
- 测试执行串行锁(SemaphoreSlim,防客户端超时后任务占用 UI 线程并发污染)
- 标准路径清单/XML 增加自动测试_Free

Bug 修复:
- AnimationControlViewModel.InvalidateLastGeneratedReport(跨测试碰撞报告残留)
- 真实物体身份校验 ReferenceEquals→InstanceGuid(NW ModelItem 实例不保证同引用)
- 真实物体动态解析(ModelPath 跨会话不稳定,禁止硬编码 PathId)
- PathImportValidity 测试点 Id 随机化(PathPoints.Id 全局主键,p1/p2 固定会冲突)
- start-navisworks.ps1:启动前清理 AutoSave(避免恢复弹窗拦截)、文件关联打开模型、dismiss 兜底、启动 15s→4.4s

验证:集成测试 13/13 通过,完整集 6min→59.6s(动画 15fps/5s)
2026-08-04 18:13:26 +08:00

45 lines
2.2 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 Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
namespace NavisworksTransport.UnitTests.Integration
{
/// <summary>
/// 碰撞报告结构断言(覆盖计划 T06
///
/// 验证报告内容的完整性与数据一致性,不依赖具体碰撞数值(碰撞数随模型数据变化)。
/// 适用:虚拟物体碰撞测试、真实物体碰撞测试。
/// </summary>
internal static class CollisionReportAssertions
{
public static void AssertReportStructure(JObject data, JObject route)
{
Assert.IsNotNull(data, "缺少测试结果 data");
Assert.IsNotNull(route, "缺少 route");
JObject report = (JObject)data["report"];
Assert.IsNotNull(report, "缺少碰撞报告");
// 路径关联
Assert.IsFalse(string.IsNullOrWhiteSpace((string)report["pathName"]), "报告路径名为空");
Assert.AreEqual((string)route["name"], (string)report["pathName"], "报告路径名不匹配");
Assert.IsFalse(string.IsNullOrWhiteSpace((string)report["routeId"]), "报告路径 ID 为空");
Assert.AreEqual((string)route["id"], (string)report["routeId"], "报告路径 ID 不匹配");
// 数据库记录关联
Assert.IsTrue((int)report["resultId"] > 0, "报告结果 ID 无效");
// 碰撞数据一致性(不依赖具体碰撞数)
Assert.IsTrue((int)report["totalCollisions"] >= 0, "碰撞总数不能为负");
Assert.IsTrue((int)report["uniqueCollidedObjectsCount"] >= 0, "唯一碰撞对象数不能为负");
Assert.IsTrue(
(int)report["uniqueCollidedObjectsCount"] <= (int)report["totalCollisions"],
"去重对象数不应超过碰撞总数");
// 运动物体信息与截图
Assert.IsFalse(string.IsNullOrWhiteSpace((string)report["movingObjectInfo"]), "报告缺少运动物体信息");
Assert.IsTrue((bool)report["hasScreenshots"], "碰撞报告应包含截图");
Assert.IsTrue((int)report["screenshotCount"] > 0, "截图数量应大于 0");
}
}
}