using System.Linq; using Centron.BusinessLogic; using Centron.BusinessLogic.Services; using Centron.Interfaces.BL; using Centron.Tests.EndToEnd.Infrastructure; using Xunit.Abstractions; namespace Centron.Tests.EndToEnd.Tests.Services.CachedTables; public class GeneralCachedTableTests : EndToEndTest { public GeneralCachedTableTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } public override void Execute() { PrepareDatabase(); using var session = new BLSession(); session.GetBL().RepairIfNecessaryCacheStatistic(); Verifier.VerifySql("CachedTableStatistics_Check", "SELECT TableName, IsUpdateRequested, IsUpdating FROM CachedTableStatistics"); session.GetBL().ExecuteCacheUpdates().ThrowIfError(); var cacheTableNames = session.GetBL().GetCachedTableNames().ToList(); foreach (var tableName in cacheTableNames) { Verifier.VerifySql($"CacheTable_{tableName}_ItemCountCheck", $"SELECT COUNT(*) FROM {tableName}"); } // Test optimized update PrepareDatabaseForOptimizedTest(); session.GetBL().ExecuteOptimizedCacheUpdates().ThrowIfError(); foreach (var tableName in cacheTableNames) { Verifier.VerifySql($"CacheTable_{tableName}_ItemCountCheckAfterOptimized", $"SELECT COUNT(*) FROM {tableName}"); } } private void PrepareDatabase() { Sql("UPDATE ARTIK SET HasWorkItems = 1 WHERE I3D IN (1218,162,136)"); } private void PrepareDatabaseForOptimizedTest() { Sql("UPDATE hlpdsk_requests SET GeaendertDatum = GETDATE() WHERE I3D IN (10460, 6377)"); Sql("DELETE FROM CacheTicketStatistic WHERE I3D = 1278"); } }