feat(configdb): native alarm source repository CRUD + eager-load includes
This commit is contained in:
+28
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user