feat(configdb): EF mappings + DbSets for native alarm source entities

This commit is contained in:
Joseph Doherty
2026-05-29 15:52:33 -04:00
parent 913441972e
commit 63f1ec282f
4 changed files with 108 additions and 0 deletions
@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase;
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests;
public class NativeAlarmSourceSchemaTests
{
private static ScadaBridgeDbContext NewContext()
{
var opts = new DbContextOptionsBuilder<ScadaBridgeDbContext>()
.UseSqlite("DataSource=:memory:")
.Options;
var ctx = new ScadaBridgeDbContext(opts);
ctx.Database.OpenConnection();
ctx.Database.EnsureCreated();
return ctx;
}
[Fact]
public async Task TemplateNativeAlarmSource_PersistsViaTemplate()
{
using var ctx = NewContext();
var t = new Template("T1");
t.NativeAlarmSources.Add(new TemplateNativeAlarmSource("Src1") { ConnectionName = "C", SourceReference = "r" });
ctx.Templates.Add(t);
await ctx.SaveChangesAsync();
Assert.Single(ctx.TemplateNativeAlarmSources);
}
[Fact]
public async Task InstanceNativeAlarmSourceOverride_DbSetIsMapped()
{
using var ctx = NewContext();
Assert.Equal(0, await ctx.InstanceNativeAlarmSourceOverrides.CountAsync());
}
}