Files
continuousimprovement/tests/Strata.ContinuousImprovement.Biz.Test.Unit/ChargeCode/Opportunities/OpportunityDetailLevelQueryTests.cs
T

79 lines
3.7 KiB
C#

using Microsoft.Data.SqlClient;
using Moq;
using NUnit.Framework;
using Strata.ContinuousImprovement.Biz.ChargeCode.Opportunities;
using Strata.ContinuousImprovement.Biz.Shared;
using Strata.ContinuousImprovement.Biz.Test.Unit.Utilities;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VerifyNUnit;
using VerifyTests;
namespace Strata.ContinuousImprovement.Biz.Test.Unit.ChargeCode.Opportunities
{
[TestFixture, Category("Unit")]
public class OpportunityDetailLevelQueryTests
{
private VerifySettings _verifySettings;
[SetUp]
public void TestSetup()
{
_verifySettings = TestExtensions.TestSettings();
}
[TestCaseSource(nameof(OpportunityDetailLevelQueryTestCases))]
public async Task OpportunityDetailLevelQueryTest(OpportunityLevel opportunityLevel, QueryHelper encounterQueryHelper,
QueryHelper opportunityLevelQueryHelper)
{
var query = new OpportunityDetailLevelQuery(opportunityLevel, encounterQueryHelper, opportunityLevelQueryHelper);
var result = query.GetQuery();
await Verifier.Verify(result, _verifySettings)
.UseFileName(TestContext.CurrentContext.TestName());
}
public static IEnumerable<TestCaseData> OpportunityDetailLevelQueryTestCases()
{
var configuration = Mock.Of<Biz.Configuration.Configuration>();
configuration.DepartmentRollupGlobalId = "";
var sqlParameters = new SqlParameter[] {
new SqlParameter("@chargeCodeIds", new List<int> { 1, 2, 3 }),
new SqlParameter("@caseTypeIds", new List<int> { 1, 2, 3 }),
new SqlParameter("@startDate", new DateTime(2023,1,1)),
new SqlParameter("@endDate", new DateTime(2024,1,1)),
new SqlParameter("@isBaseline", true)
};
foreach (var parameterName in new[] { "@caseTypeIds", "@indicatorIds" })
{
sqlParameters[1].ParameterName = parameterName;
foreach (var isUsingSnowflake in new[] { true, false })
{
foreach (var oppLevel in Enum.GetValues<OpportunityLevel>())
{
switch (oppLevel)
{
case OpportunityLevel.ServiceLine:
foreach (var serviceLine in new[] { "Sg2 Service Line Crosswalk", "Service Line" })
{
yield return new TestCaseData(oppLevel,
new EncounterGroupQueryHelper(sqlParameters),
new OpportunityLevelQueryHelper(oppLevel, configuration, serviceLine, $"{(serviceLine.Replace(" ", ""))}Id"))
.SetName($"{{m}} {Enum.GetName<OpportunityLevel>(oppLevel)} {parameterName.Substring(1)} {serviceLine} {(isUsingSnowflake ? "Snowflake" : "")}");
}
break;
default:
yield return new TestCaseData(oppLevel,
new EncounterGroupQueryHelper(sqlParameters),
new OpportunityLevelQueryHelper(oppLevel, configuration, "", ""))
.SetName($"{{m}} {Enum.GetName<OpportunityLevel>(oppLevel)} {parameterName.Substring(1)} Default {(isUsingSnowflake ? "Snowflake" : "")}");
break;
}
}
}
}
}
}
}