fix(transport): case-insensitive remaining library lookups; base-only template reads for import targets (ScadaBridge#95)
- Preview matches template folders, shared scripts, external systems, SMTP (by Host) and SMS (by AccountSid) with the #93 ToNameLookup comparer (OrdinalIgnoreCase, first wins, never throws), matching SQL Server's case-insensitive collation, so a differently-cased target row is reported as a conflict instead of New. - Apply-side in-memory lookups do the same: ApplyTemplateFoldersAsync, the template folder-id map, ResolveFolderParentEdgesAsync, ApplySmtpConfigsAsync and ApplySmsConfigsAsync. An Overwrite now updates the existing row instead of adding a duplicate (folder names are only unique per parent, so the old ToDictionary could also throw). - New ITemplateEngineRepository.GetBaseTemplatesWithChildrenAsync filters IsDerived in SQL. Preview and the Overwrite load in ApplyTemplatesAsync use it, so a derived slot template that shares a bundled name is never the import target. GetTemplatesWithChildrenAsync is unchanged for the id-keyed callers (export closure, rewire passes), which can need derived rows. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
+21
@@ -221,6 +221,27 @@ public class TemplateEngineRepositoryTests : IDisposable
|
||||
Assert.Equal("Alpha", result[0].Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ScadaBridge#95: the base-only bulk variant skips derived templates that share a
|
||||
/// requested name, while the general variant still returns them.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task GetBaseTemplatesWithChildrenAsync_SkipsDerivedRowsSharingTheName()
|
||||
{
|
||||
var baseT = new Template("Alpha");
|
||||
var derived = new Template("Alpha") { IsDerived = true };
|
||||
var derivedOnly = new Template("Beta") { IsDerived = true };
|
||||
_context.Templates.AddRange(baseT, derived, derivedOnly);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var baseOnly = await _repository.GetBaseTemplatesWithChildrenAsync(new[] { "Alpha", "Beta" });
|
||||
var all = await _repository.GetTemplatesWithChildrenAsync(new[] { "Alpha", "Beta" });
|
||||
|
||||
Assert.Equal(baseT.Id, Assert.Single(baseOnly).Id);
|
||||
Assert.Equal(3, all.Count);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the parent template id is preserved so the inheritance chain can be walked.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user