using Microsoft.EntityFrameworkCore; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates; using ZB.MOM.WW.ScadaBridge.Commons.Types.Templates; using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Repositories; namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests; /// /// Gitea #66: reads only a /// template's inheritance chain + composition closure — one projection query per closure depth — /// instead of the whole library that /// materialises. Asserted against real SQL on SQLite with the reader commands recorded. /// public class TemplateAnalysisClosureRepositoryTests : IDisposable { private const int UnrelatedTemplates = 40; private const string BigBody = "/* script body that must never be read by analysis */"; private readonly SqlReaderCommandRecorder _recorder = new(); private readonly ScadaBridgeDbContext _context; private readonly TemplateEngineRepository _repository; /// Initializes the test class with an in-memory context and repository. public TemplateAnalysisClosureRepositoryTests() { _context = SqliteTestHelper.CreateInMemoryContext(_recorder); _repository = new TemplateEngineRepository(_context, new TemplateGraphWatermark()); } /// Releases the resources held by this test class. public void Dispose() { _context.Database.CloseConnection(); _context.Dispose(); } private async Task