using Microsoft.EntityFrameworkCore; using Strata.ContinuousImprovement.Biz.All.Opportunities; using Strata.ContinuousImprovement.Biz.ChargeCode.Opportunities; using Strata.ContinuousImprovement.Biz.Cube; using Strata.ContinuousImprovement.Biz.DbContexts; using Strata.ContinuousImprovement.Biz.DbContexts.Jazz.Dimensions; using Strata.ContinuousImprovement.Biz.DbContexts.Reports; using Strata.ContinuousImprovement.Biz.DbContexts.Security; using Strata.ContinuousImprovement.Biz.Encounter.Opportunities; using Strata.ContinuousImprovement.Biz.Exploration.CaseTypeFamilies; using Strata.ContinuousImprovement.Biz.Exploration.Opportunities; using Strata.ContinuousImprovement.Biz.Filter; using Strata.ContinuousImprovement.Biz.FreeForm.Initiatives; using Strata.ContinuousImprovement.Biz.FreeForm.Opportunities; using Strata.ContinuousImprovement.Biz.GeneralLedger.Details; using Strata.ContinuousImprovement.Biz.GeneralLedger.Opportunities; using Strata.ContinuousImprovement.Biz.GMDN; using Strata.ContinuousImprovement.Biz.InitiativeRollupColumns; using Strata.ContinuousImprovement.Biz.Initiatives; using Strata.ContinuousImprovement.Biz.Network; using Strata.ContinuousImprovement.Biz.Payroll.Opportunities; using Strata.ContinuousImprovement.Biz.PeerGroups; using Strata.ContinuousImprovement.Biz.Population; using Strata.ContinuousImprovement.Biz.QualityVariation.Breakdowns; using Strata.ContinuousImprovement.Biz.QualityVariation.Events; using Strata.ContinuousImprovement.Biz.QualityVariation.Metrics; using Strata.ContinuousImprovement.Biz.QualityVariation.Opportunities; using Strata.ContinuousImprovement.Biz.Score; using Strata.ContinuousImprovement.Biz.Security; using Strata.ContinuousImprovement.Biz.Shared; using Strata.ContinuousImprovement.Biz.Test.Unit.Utilities; using Strata.ContinuousImprovement.Biz.UserProfiles; using Strata.ContinuousImprovement.Biz.UserSetting; using Strata.ContinuousImprovement.Biz.UtilizationVariation; using Strata.ContinuousImprovement.Biz.UtilizationVariation.Opportunities; using Strata.ContinuousImprovement.Biz.UtilizationVariation.VariationCaseTypes; using Strata.Stratasphere.Biz.DbContexts; using System.Diagnostics.CodeAnalysis; namespace Strata.ContinuousImprovement.Biz.Test.Integration.JazzIntegrationTests { [ExcludeFromCodeCoverage] [TestFixture, Category("Integration"), Category("CCI")] public partial class TestJazzDbContext : IntegrationTestBase { public async Task TestGeneric(TestContext testContext) where T : class { try { var count = await ((DbContext)JazzDbContext).Set().CountAsync(CancellationToken.None); Assert.That(count, Is.GreaterThanOrEqualTo(0)); if (count == 0) { return; } var result = await ((DbContext)JazzDbContext).Set().FirstOrDefaultAsync(CancellationToken.None); Assert.That(result, Is.Not.Null.And.InstanceOf()); } catch { // ILB } } [Test] public async Task JazzDbTestCases() { var types = ((DbContext)JazzDbContext).Model.GetEntityTypes() .Select(e => e.ClrType).OrderBy(c => c.Name).ToList(); foreach (var type in types) { switch (type.Name) { case nameof(AllOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(CaseTypeFamily): TestGeneric(TestContext.CurrentContext); break; case nameof(CciUserSetting): TestGeneric(TestContext.CurrentContext); break; case nameof(CCOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(CCOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(CCOpportunityDetailQueryResult): TestGeneric(TestContext.CurrentContext); break; case nameof(CCOpportunityLevelCaseQueryResult): TestGeneric(TestContext.CurrentContext); break; case nameof(ChargeCode.ChargeCode): TestGeneric(TestContext.CurrentContext); break; case nameof(ChargeCodeOpportunityDetail): TestGeneric(TestContext.CurrentContext); break; case nameof(ChargeCodeOpportunityLevelCase): TestGeneric(TestContext.CurrentContext); break; case nameof(Configuration.Configuration): TestGeneric(TestContext.CurrentContext); break; case nameof(CostComponentRollup): TestGeneric(TestContext.CurrentContext); break; case nameof(DboUserSetting): TestGeneric(TestContext.CurrentContext); break; case nameof(DimCaseType): TestGeneric(TestContext.CurrentContext); break; case nameof(DimCostComponent): TestGeneric(TestContext.CurrentContext); break; case nameof(DimDeviceIdentifier): TestGeneric(TestContext.CurrentContext); break; case nameof(DimSupply): TestGeneric(TestContext.CurrentContext); break; case nameof(DimEntity): TestGeneric(TestContext.CurrentContext); break; case nameof(StringValue): TestGeneric(TestContext.CurrentContext); break; case nameof(ENOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(ENOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(ENOpportunityMetricData): TestGeneric(TestContext.CurrentContext); break; case nameof(EXOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(FactGL): TestGeneric(TestContext.CurrentContext); break; case nameof(FactGLSampled): TestGeneric(TestContext.CurrentContext); break; case nameof(FactStatistic): TestGeneric(TestContext.CurrentContext); break; case nameof(FactStatisticSampledMonthly): TestGeneric(TestContext.CurrentContext); break; case nameof(FFFInitiativeTrackingData): TestGeneric(TestContext.CurrentContext); break; case nameof(FFInitiativeTrackingData): TestGeneric(TestContext.CurrentContext); break; case nameof(FFOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(FFOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(Folder): TestGeneric(TestContext.CurrentContext); break; case nameof(GLOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(GLOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(Identity): TestGeneric(TestContext.CurrentContext); break; case nameof(Initiative): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeComment): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeCriteria): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeCriteriaQueryResult): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeRollupColumn): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeRollupValue): TestGeneric(TestContext.CurrentContext); break; case nameof(InitiativeScore): TestGeneric(TestContext.CurrentContext); break; case nameof(Lock): // Lock is inaccessible due to its protection level break; case nameof(NetworkOpportunityLink): TestGeneric(TestContext.CurrentContext); break; case nameof(OpportunityMetricCohortData): TestGeneric(TestContext.CurrentContext); break; case nameof(OpportunityReport): TestGeneric(TestContext.CurrentContext); break; case nameof(PeerGroup): TestGeneric(TestContext.CurrentContext); break; case nameof(PeerGroupCriteriaMapping): TestGeneric(TestContext.CurrentContext); break; case nameof(PROpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(PROpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(QVIBreakdown): TestGeneric(TestContext.CurrentContext); break; case nameof(QVIEvent): TestGeneric(TestContext.CurrentContext); break; case nameof(QVIOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(REReport): TestGeneric(TestContext.CurrentContext); break; case nameof(RESQLReportRegisteredAttribute): TestGeneric(TestContext.CurrentContext); break; case nameof(S3ACLSimple): TestGeneric(TestContext.CurrentContext); break; case nameof(S3SimplePermission): TestGeneric(TestContext.CurrentContext); break; case nameof(S3SimplePermissionDefault): TestGeneric(TestContext.CurrentContext); break; case nameof(ScoreAttribute): TestGeneric(TestContext.CurrentContext); break; case nameof(ScoreDimension): TestGeneric(TestContext.CurrentContext); break; case nameof(SimplePermission): TestGeneric(TestContext.CurrentContext); break; case nameof(SourceOfSavingsReport): TestGeneric(TestContext.CurrentContext); break; case nameof(SystemSetting): TestGeneric(TestContext.CurrentContext); break; case nameof(UserGroup): TestGeneric(TestContext.CurrentContext); break; case nameof(UserProfile): TestGeneric(TestContext.CurrentContext); break; case nameof(UVCaseType): TestGeneric(TestContext.CurrentContext); break; case nameof(UVOpportunity): TestGeneric(TestContext.CurrentContext); break; case nameof(VariationOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(ExplorationVariationOpportunityDataModel): TestGeneric(TestContext.CurrentContext); break; case nameof(ViewScoreAttribute): TestGeneric(TestContext.CurrentContext); break; case nameof(DimAprdrg): TestGeneric(TestContext.CurrentContext); break; case nameof(DimCpt): TestGeneric(TestContext.CurrentContext); break; case nameof(DimIcd10Dx): TestGeneric(TestContext.CurrentContext); break; case nameof(DimIcd10Px): TestGeneric(TestContext.CurrentContext); break; case nameof(DimMsdrg): TestGeneric(TestContext.CurrentContext); break; case nameof(DimMsdrgRollup): TestGeneric(TestContext.CurrentContext); break; case nameof(QviMetrics): TestGeneric(TestContext.CurrentContext); break; default: var pathArr = TestContext.CurrentContext.TestDirectory.Split(Path.DirectorySeparatorChar); var path = string.Join(Path.DirectorySeparatorChar, pathArr[..^3].Append("JazzIntegrationTests")); var fileName = Path.Combine(path, $"{nameof(TestJazzDbContext)}_{type.Name}.cs"); if (File.Exists(fileName)) break; var testFile = @" namespace Strata.ContinuousImprovement.Biz.Test.Integration.ContinuousImprovementServiceTests { [TestFixture, Category(""Integration""), Category(""CCI"")] public partial class TestJazzDbContext : IntegrationTestBase { [Test] public async Task Test" + type.Name + @"() { TestGeneric<" + type.Name + @">(TestContext.CurrentContext); } } } "; File.WriteAllText(fileName, testFile); break; } } await Verify(types, verifySettings) .UseFileName(TestContext.CurrentContext.TestName()); } } }