feat(configdb): native alarm source repository CRUD + eager-load includes

This commit is contained in:
Joseph Doherty
2026-05-29 15:56:35 -04:00
parent 63f1ec282f
commit aedd17ca7f
3 changed files with 138 additions and 0 deletions
@@ -147,4 +147,32 @@ public class TemplateEngineRepositoryTests : IDisposable
Assert.NotNull(loaded);
Assert.Equal(baseTemplate.Id, loaded!.ParentTemplateId);
}
[Fact]
public async Task AddAndGetNativeAlarmSourcesByTemplateId_RoundTrips()
{
var t = new Template("T");
_context.Templates.Add(t);
await _context.SaveChangesAsync();
await _repository.AddTemplateNativeAlarmSourceAsync(
new TemplateNativeAlarmSource("S") { TemplateId = t.Id, ConnectionName = "C", SourceReference = "r" });
await _context.SaveChangesAsync();
var list = await _repository.GetNativeAlarmSourcesByTemplateIdAsync(t.Id);
Assert.Single(list);
Assert.Equal("S", list[0].Name);
}
[Fact]
public async Task GetTemplateWithChildren_IncludesNativeAlarmSources()
{
var t = new Template("T");
t.NativeAlarmSources.Add(new TemplateNativeAlarmSource("S") { ConnectionName = "C", SourceReference = "r" });
_context.Templates.Add(t);
await _context.SaveChangesAsync();
var loaded = await _repository.GetTemplateWithChildrenAsync(t.Id);
Assert.Single(loaded!.NativeAlarmSources);
}
}