Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Services/TemplatePathFormatterTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

48 lines
2.0 KiB
C#

using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Services;
public class TemplatePathFormatterTests
{
private static Dictionary<int, TemplateFolder> Folders(params TemplateFolder[] f) => f.ToDictionary(x => x.Id);
/// <summary>Verifies that a root template is formatted as its name only.</summary>
[Fact]
public void RootTemplate_IsNameOnly()
{
var t = new Template("Motor Controller") { Id = 1, FolderId = null };
Assert.Equal("Motor Controller", TemplatePathFormatter.Format(t, Folders()));
}
/// <summary>Verifies that a nested template is formatted with its folder chain joined by slashes.</summary>
[Fact]
public void NestedTemplate_JoinsFolderChainWithSlashes()
{
var controllers = new TemplateFolder("Controllers") { Id = 10, ParentFolderId = null };
var conveyor = new TemplateFolder("Conveyor") { Id = 11, ParentFolderId = 10 };
var t = new Template("MES Line Controller") { Id = 1, FolderId = 11 };
Assert.Equal("Controllers / Conveyor / MES Line Controller",
TemplatePathFormatter.Format(t, Folders(controllers, conveyor)));
}
/// <summary>Verifies that an unknown folder id falls back to the name only without throwing.</summary>
[Fact]
public void UnknownFolderId_FallsBackToNameOnly_WithoutThrowing()
{
var t = new Template("Orphan") { Id = 1, FolderId = 999 };
Assert.Equal("Orphan", TemplatePathFormatter.Format(t, Folders()));
}
/// <summary>Verifies that a cycle in the folder chain terminates instead of looping forever.</summary>
[Fact]
public void FolderCycle_Terminates()
{
var a = new TemplateFolder("A") { Id = 1, ParentFolderId = 2 };
var b = new TemplateFolder("B") { Id = 2, ParentFolderId = 1 };
var t = new Template("T") { Id = 1, FolderId = 1 };
var s = TemplatePathFormatter.Format(t, Folders(a, b));
Assert.EndsWith("T", s); // no hang, no exception
}
}