Template
chore: deploy initial code base
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Strata.ContinuousImprovement.Biz.FiscalMonths;
|
||||
using Strata.ContinuousImprovement.Biz.Generics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using config = Strata.ContinuousImprovement.Biz.Configuration;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.Configuration
|
||||
{
|
||||
|
||||
[TestFixture, Category("Unit")]
|
||||
public class ConfigurationTest
|
||||
{
|
||||
private IEnumerable<OpportunityTypes> excludedOpportTypes = new List<OpportunityTypes>()
|
||||
{
|
||||
OpportunityTypes.Blank,
|
||||
OpportunityTypes.Network
|
||||
};
|
||||
private IEnumerable<OpportunityTypes> OpportTypes { get; set; }
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetup()
|
||||
{
|
||||
OpportTypes = Enum.GetValues(typeof(OpportunityTypes))
|
||||
.Cast<OpportunityTypes>()
|
||||
.Where(x => !excludedOpportTypes.Contains(x));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(ConfigTestCases))]
|
||||
public void TestConfiguration(string rollup, string ids, int breakdown,
|
||||
IEnumerable<int> configuredIds, string name, string plural)
|
||||
{
|
||||
var config = new config.Configuration
|
||||
{
|
||||
DepartmentRollupGlobalId = rollup,
|
||||
EntityIdsCSV = string.IsNullOrEmpty(rollup) ? "" : ids,
|
||||
CustomEntityIdsCSV = string.IsNullOrEmpty(rollup) ? ids : "",
|
||||
QVIOpportunityBreakdown = (Biz.Configuration.Configuration.QVIOpportunityBreakdowns)breakdown
|
||||
};
|
||||
config.ConfiguredEntityIds.Should().AllBeEquivalentTo(configuredIds);
|
||||
config.QVIOpportunityBreakdownEnum.Should().Be(breakdown);
|
||||
config.QVIOpportunityBreakdownName.Should().Be(name);
|
||||
config.QVIOpportunityBreakdownNamePlural.Should().Be(plural);
|
||||
config.ServiceLineDimensionGuid.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(StartEndDateTestCases))]
|
||||
public void TestGetBaselineStartDate(DateTime expectedStartDate, DateTime endDate)
|
||||
{
|
||||
var configuration = GetConfigurationByDate(endDate);
|
||||
var opportunityTypeIds = Enum.GetValues<OpportunityTypes>().Cast<byte>().ToList();
|
||||
foreach (var opType in OpportTypes.Where(t => opportunityTypeIds.Contains((byte)t)))
|
||||
{
|
||||
var actualStartDate = configuration.GetBaselineStartDate(opType);
|
||||
actualStartDate.Should().Be(expectedStartDate);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(StartEndDateTestCases))]
|
||||
public void TestGetLastFiscalYearStartDate(DateTime expectedStartDate, DateTime endDate)
|
||||
{
|
||||
var configuration = GetConfigurationByDate(endDate, true);
|
||||
|
||||
var actualStartDate = configuration.GetLastFiscalYearStartDate();
|
||||
expectedStartDate = expectedStartDate.AddYears(-1);
|
||||
actualStartDate.Should().Be(expectedStartDate);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(StartEndDateTestCases))]
|
||||
public void TestGetFiscalYearStartDate(DateTime expectedStartDate, DateTime endDate)
|
||||
{
|
||||
var configuration = GetConfigurationByDate(endDate, true);
|
||||
|
||||
var actualStartDate = configuration.GetFiscalYearStartDate();
|
||||
actualStartDate.Should().Be(expectedStartDate);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TrackingCurrentMonthEndDateTestCases))]
|
||||
public void TestTrackingCurrentMonthEndDate(
|
||||
OpportunityTypes opportunityType,
|
||||
DateTime trackingCurrentMonth,
|
||||
DateTime expectedEndDate)
|
||||
{
|
||||
var configuration = GetConfigurationWithTrackingMonth(trackingCurrentMonth, opportunityType);
|
||||
|
||||
var actualEndDate = configuration.TrackingCurrentMonthEndDate(opportunityType);
|
||||
|
||||
actualEndDate.Should().Be(expectedEndDate);
|
||||
actualEndDate.Hour.Should().Be(0);
|
||||
actualEndDate.Minute.Should().Be(0);
|
||||
actualEndDate.Second.Should().Be(0);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TrackingCurrentMonthEndDateTestCases))]
|
||||
public void TestGetTrackingCurrentMonthEndDate(
|
||||
OpportunityTypes opportunityType,
|
||||
DateTime trackingCurrentMonth,
|
||||
DateTime expectedEndDate)
|
||||
{
|
||||
var configuration = GetConfigurationWithTrackingMonth(trackingCurrentMonth, opportunityType);
|
||||
|
||||
var actualEndDate = configuration.GetTrackingCurrentMonthEndDate(opportunityType);
|
||||
|
||||
actualEndDate.Should().Be(expectedEndDate.AddDays(-1));
|
||||
}
|
||||
|
||||
#region Configuration Test Cases
|
||||
|
||||
private static IEnumerable<TestCaseData> ConfigTestCases()
|
||||
{
|
||||
yield return new TestCaseData("Rollup", "1,2,3,4", 4,
|
||||
new[] { 1, 2, 3, 4 }, "Breakdown", "Breakdowns")
|
||||
.SetName("Default With Rollup");
|
||||
yield return new TestCaseData("", "1,2,3,4", 4,
|
||||
new[] { 1, 2, 3, 4 }, "Breakdown", "Breakdowns")
|
||||
.SetName("Default w/o Rollup");
|
||||
yield return new TestCaseData("Rollup", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.Entity,
|
||||
new[] { 1, 2, 3, 4 }, "Entity", "Entities")
|
||||
.SetName("Entity With Rollup");
|
||||
yield return new TestCaseData("", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.Entity,
|
||||
new[] { 1, 2, 3, 4 }, "Entity", "Entities")
|
||||
.SetName("Entity w/o Rollup");
|
||||
yield return new TestCaseData("Rollup", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.ServiceLine,
|
||||
new[] { 1, 2, 3, 4 }, "Service Line", "Service Lines")
|
||||
.SetName("Service Line With Rollup");
|
||||
yield return new TestCaseData("", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.ServiceLine,
|
||||
new[] { 1, 2, 3, 4 }, "Service Line", "Service Lines")
|
||||
.SetName("Service Line w/o Rollup");
|
||||
yield return new TestCaseData("Rollup", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.PhysicianSpecialty,
|
||||
new[] { 1, 2, 3, 4 }, "Physician Specialty", "Physician Specialties")
|
||||
.SetName("Physician Specialty With Rollup");
|
||||
yield return new TestCaseData("", "1,2,3,4",
|
||||
(int)config.Configuration.QVIOpportunityBreakdowns.PhysicianSpecialty,
|
||||
new[] { 1, 2, 3, 4 }, "Physician Specialty", "Physician Specialties")
|
||||
.SetName("Physician Specialty w/o Rollup");
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> StartEndDateTestCases()
|
||||
{
|
||||
yield return new TestCaseData(new DateTime(2023, 3, 1), new DateTime(2024, 2, 29));
|
||||
yield return new TestCaseData(new DateTime(2024, 3, 1), new DateTime(2025, 2, 28));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> TrackingCurrentMonthEndDateTestCases()
|
||||
{
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.ChargeCode,
|
||||
new DateTime(2024, 3, 15),
|
||||
new DateTime(2024, 4, 1))
|
||||
.SetName("ChargeCode - March 2024");
|
||||
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.QualityVariation,
|
||||
new DateTime(2024, 6, 20),
|
||||
new DateTime(2024, 7, 1))
|
||||
.SetName("QualityVariation - June 2024");
|
||||
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.Variation,
|
||||
new DateTime(2024, 12, 5),
|
||||
new DateTime(2025, 1, 1))
|
||||
.SetName("Variation - December 2024");
|
||||
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.OrgDefined,
|
||||
new DateTime(2024, 2, 10),
|
||||
new DateTime(2024, 3, 1))
|
||||
.SetName("OrgDefined - February 2024");
|
||||
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.Exploration,
|
||||
new DateTime(2024, 1, 31),
|
||||
new DateTime(2024, 2, 1))
|
||||
.SetName("Exploration - January 2024");
|
||||
|
||||
yield return new TestCaseData(
|
||||
OpportunityTypes.ChargeCode,
|
||||
new DateTime(2024, 2, 29),
|
||||
new DateTime(2024, 3, 1))
|
||||
.SetName("ChargeCode - Leap Year February");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils
|
||||
|
||||
private static config.Configuration GetConfigurationByDate(DateTime date, bool isFiscalMonthResolver = false)
|
||||
{
|
||||
var configuration = new config.Configuration
|
||||
{
|
||||
FiscalYearID = (short)date.Year,
|
||||
OrgDefinedEndDate = date,
|
||||
VariationEndDate = date,
|
||||
QualityVariationEndDate = date
|
||||
};
|
||||
|
||||
if (isFiscalMonthResolver)
|
||||
{
|
||||
var lastFiscalMonth = new FiscalMonth
|
||||
{
|
||||
FiscalMonthId = (byte)date.Month
|
||||
};
|
||||
var fmr = Mock.Of<IFiscalMonthResolver>();
|
||||
Mock.Get(fmr)
|
||||
.Setup(s => s.LastFiscalMonth())
|
||||
.Returns(() => lastFiscalMonth);
|
||||
configuration.FiscalMonthResolver = fmr;
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private static config.Configuration GetConfigurationWithTrackingMonth(
|
||||
DateTime trackingCurrentMonth,
|
||||
OpportunityTypes opportunityType)
|
||||
{
|
||||
var configuration = new config.Configuration();
|
||||
|
||||
switch (opportunityType)
|
||||
{
|
||||
case OpportunityTypes.ChargeCode:
|
||||
configuration.OrgDefinedTrackingCurrentMonth = trackingCurrentMonth;
|
||||
break;
|
||||
case OpportunityTypes.QualityVariation:
|
||||
configuration.QualityVariationTrackingCurrentMonth = trackingCurrentMonth;
|
||||
break;
|
||||
default:
|
||||
configuration.VariationTrackingCurrentMonth = trackingCurrentMonth;
|
||||
break;
|
||||
}
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user