fix(tests): 修复 AliasTreeTests 编译错误并更新过时旧格式兼容测试
- SetAlias 调用补全缺失的 alias 参数(DeleteByPathPrefix 测试) - 移除 4 个旧格式兼容测试,改为期望抛 FormatException (FromKey 已按 AGENTS.md "不向后兼容" 原则移除旧格式支持)
This commit is contained in:
parent
f86e8c8bf4
commit
7f3be8495c
@ -59,19 +59,18 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FromKey_OldFormat_ShouldRetroCompatible()
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void FromKey_OldFormat_ShouldThrow()
|
||||
{
|
||||
var id = AliasNodeIdentity.FromKey("building/floor/wall#2");
|
||||
Assert.AreEqual("", id.IndexPath);
|
||||
Assert.AreEqual("building/floor/wall#2", id.DisplayPath);
|
||||
// 旧格式(无 || 分隔符)已不再支持,按 AGENTS.md "不向后兼容" 原则抛 FormatException
|
||||
AliasNodeIdentity.FromKey("building/floor/wall#2");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FromKey_OldFormatNoIndex_ShouldParse()
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void FromKey_OldFormatNoIndex_ShouldThrow()
|
||||
{
|
||||
var id = AliasNodeIdentity.FromKey("building/floor");
|
||||
Assert.AreEqual("", id.IndexPath);
|
||||
Assert.AreEqual("building/floor", id.DisplayPath);
|
||||
AliasNodeIdentity.FromKey("building/floor");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -99,10 +98,10 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TryParseKey_OldFormat_ShouldSucceed()
|
||||
public void TryParseKey_OldFormat_ShouldReturnFalse()
|
||||
{
|
||||
Assert.IsTrue(AliasNodeIdentity.TryParseKey("path#0", out var id));
|
||||
Assert.AreEqual("", id.IndexPath);
|
||||
// 旧格式(无 || 分隔符)已不再支持
|
||||
Assert.IsFalse(AliasNodeIdentity.TryParseKey("path#0", out _));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -279,9 +278,9 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
public void DeleteByPathPrefix_ShouldRemoveAllUnderPath()
|
||||
{
|
||||
var store = CreateStore();
|
||||
store.SetAlias(Id("building/floor/1"));
|
||||
store.SetAlias(Id("building/floor/2"));
|
||||
store.SetAlias(Id("building/roof/3"));
|
||||
store.SetAlias(Id("building/floor/1"), "别名1");
|
||||
store.SetAlias(Id("building/floor/2"), "别名2");
|
||||
store.SetAlias(Id("building/roof/3"), "别名3");
|
||||
|
||||
store.DeleteAliasesByPathPrefix("building/floor");
|
||||
|
||||
@ -343,19 +342,16 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
Assert.AreEqual(0, store.Count);
|
||||
}
|
||||
|
||||
// ── 新格式 → 旧格式 兼容 ──
|
||||
// ── 旧格式已不支持(AGENTS.md "不向后兼容" 原则)──
|
||||
|
||||
[TestMethod]
|
||||
public void OldFormatKey_StillWorks()
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void OldFormatKey_ShouldThrow()
|
||||
{
|
||||
var store = CreateStore();
|
||||
string oldKey = "building/floor/wall#0";
|
||||
// 旧格式 key 无 || 分隔符,FromKey 应抛 FormatException
|
||||
store.SetAlias(AliasNodeIdentity.FromKey(oldKey), "别名");
|
||||
Assert.AreEqual("别名", store.GetAlias(AliasNodeIdentity.FromKey(oldKey)));
|
||||
|
||||
// 同一个节点用新格式读取
|
||||
var newId = new AliasNodeIdentity("", "building/floor/wall#0");
|
||||
Assert.AreEqual("别名", store.GetAlias(newId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user