Template
chore: deploy initial code base
This commit is contained in:
+185
@@ -0,0 +1,185 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Strata.ContinuousImprovement.Biz.Dtos;
|
||||
using Strata.ContinuousImprovement.Biz.Encounter.Opportunities;
|
||||
using Strata.ContinuousImprovement.Biz.Mappers;
|
||||
using Strata.ContinuousImprovement.Biz.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.Encounter
|
||||
{
|
||||
[TestFixture, Category("Unit")]
|
||||
public class EncounterOpportunityMetricTest
|
||||
{
|
||||
private ENOpportunityDto opportunity;
|
||||
private ENOpportunityDataModelWithFilters model;
|
||||
|
||||
[SetUp]
|
||||
public void TestSetup()
|
||||
{
|
||||
opportunity = new ENOpportunityDto
|
||||
{
|
||||
ConfigurationGuid = Guid.NewGuid(),
|
||||
Name = "Test Encounter Opportunity",
|
||||
EncounterGroup = 0,
|
||||
OpportunityLevel = 1,
|
||||
EncounterGroups = new List<string>
|
||||
{
|
||||
"CaseType|CaseType|1"
|
||||
},
|
||||
OpportunityLevels = new List<string>()
|
||||
{
|
||||
"ENT|ENT|1"
|
||||
},
|
||||
IsBaseline = true
|
||||
};
|
||||
model = opportunity.MapToDataModel(null);
|
||||
model.OpportunityGuid = Guid.NewGuid();
|
||||
model.AuthorGuid = Guid.NewGuid();
|
||||
model.AuthorName = "Someones Name";
|
||||
model.DateCreated = DateTime.Today;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestENOpportunityDataModel()
|
||||
{
|
||||
var data = opportunity.MapToDataModel(null);
|
||||
data.ConfigurationGuid.Should().NotBe(Guid.Empty)
|
||||
.And.Be(opportunity.ConfigurationGuid);
|
||||
data.EncounterGroup.Should().Be(opportunity.EncounterGroup);
|
||||
data.OpportunityLevel.Should().Be(Enum.GetName(typeof(OpportunityLevel), opportunity.OpportunityLevel));
|
||||
data.EncounterOpportunityLevel.Should().Be((OpportunityLevel)opportunity.OpportunityLevel);
|
||||
data.CaseTypes.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.EncounterGroups.Select(x => x).Contains(ct.Id));
|
||||
data.IsSeasonal.Should().Be(opportunity.IsSeasonal);
|
||||
data.IsBaseline.Should().Be(opportunity.IsBaseline);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEncounterOpportunityMetric()
|
||||
{
|
||||
var metric = model.MapFromDataModel();
|
||||
metric.OpportunityGuid.Should().Be(model.OpportunityGuid);
|
||||
metric.ConfigurationGuid.Should().Be(model.ConfigurationGuid);
|
||||
metric.AuthorName.Should().Be(model.AuthorName);
|
||||
metric.AuthorGuid.Should().Be(model.AuthorGuid);
|
||||
metric.Name.Should().Be(model.Name);
|
||||
metric.EncounterOpportunityLevel.Should().Be(model.EncounterOpportunityLevel);
|
||||
metric.EncounterGroup.Should().Be(model.EncounterGroup);
|
||||
metric.CaseTypes.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.EncounterGroups.Select(x => x).Contains(ct.Id));
|
||||
var filter = opportunity.EncounterGroups.First().MapToFilterHelper();
|
||||
metric.CaseTypes.First().GetHashCode().Equals(filter.GetHashCode());
|
||||
metric.PatientPopulations.Should().BeEmpty();
|
||||
metric.Entities.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.OpportunityLevels.Select(x => x).Contains(ct.Id));
|
||||
metric.ServiceLines.Should().BeEmpty();
|
||||
metric.Specialties.Should().BeEmpty();
|
||||
metric.Providers.Should().BeEmpty();
|
||||
metric.IsBaseline.Should().Be(opportunity.IsBaseline);
|
||||
metric.ConfigurationGuid.Should().NotBe(Guid.Empty);
|
||||
metric.IsSeasonal.Should().Be(opportunity.IsSeasonal);
|
||||
metric.IsBaseline.Should().Be(opportunity.IsBaseline);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetEncounterOpportunityMetricTests))]
|
||||
public void TestEncounterOpportunityMetric(ENOpportunityDto enOpportunity)
|
||||
{
|
||||
var dataModel = opportunity.MapToDataModel(null);
|
||||
var metric = dataModel.MapFromDataModel();
|
||||
metric.OpportunityGuid.Should().Be(dataModel.OpportunityGuid);
|
||||
metric.ConfigurationGuid.Should().Be(dataModel.ConfigurationGuid);
|
||||
metric.AuthorName.Should().Be(dataModel.AuthorName);
|
||||
metric.AuthorGuid.Should().Be(dataModel.AuthorGuid);
|
||||
metric.Name.Should().Be(dataModel.Name);
|
||||
metric.EncounterOpportunityLevel.Should().Be(dataModel.EncounterOpportunityLevel);
|
||||
metric.EncounterGroup.Should().Be(dataModel.EncounterGroup);
|
||||
switch ((EncounterGroup)metric.EncounterGroup)
|
||||
{
|
||||
case EncounterGroup.CaseType:
|
||||
metric.CaseTypes.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.EncounterGroups.Select(x => x).Contains(ct.Id));
|
||||
var filter = opportunity.EncounterGroups.First().MapToFilterHelper();
|
||||
metric.CaseTypes.First().GetHashCode().Equals(filter.GetHashCode());
|
||||
break;
|
||||
case EncounterGroup.PatientPopulation:
|
||||
metric.PatientPopulations.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.EncounterGroups.Select(x => x).Contains(ct.Id));
|
||||
var filter1 = opportunity.EncounterGroups.First().MapToFilterHelper();
|
||||
metric.PatientPopulations.First().GetHashCode().Equals(filter1.GetHashCode());
|
||||
break;
|
||||
}
|
||||
metric.PatientPopulations.Should().BeEmpty();
|
||||
switch (metric.EncounterOpportunityLevel)
|
||||
{
|
||||
case OpportunityLevel.Organization:
|
||||
metric.Entities.Should().BeEmpty();
|
||||
metric.ServiceLines.Should().BeEmpty();
|
||||
metric.Specialties.Should().BeEmpty();
|
||||
metric.Providers.Should().BeEmpty();
|
||||
break;
|
||||
case OpportunityLevel.Entity:
|
||||
metric.Entities.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.OpportunityLevels.Select(x => x).Contains(ct.Id));
|
||||
metric.ServiceLines.Should().BeEmpty();
|
||||
metric.Specialties.Should().BeEmpty();
|
||||
metric.Providers.Should().BeEmpty();
|
||||
break;
|
||||
case OpportunityLevel.ServiceLine:
|
||||
metric.ServiceLines.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.OpportunityLevels.Select(x => x).Contains(ct.Id));
|
||||
metric.Entities.Should().BeEmpty();
|
||||
metric.Specialties.Should().BeEmpty();
|
||||
metric.Providers.Should().BeEmpty();
|
||||
break;
|
||||
case OpportunityLevel.Specialty:
|
||||
metric.Specialties.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.OpportunityLevels.Select(x => x).Contains(ct.Id));
|
||||
metric.Entities.Should().BeEmpty();
|
||||
metric.ServiceLines.Should().BeEmpty();
|
||||
metric.Providers.Should().BeEmpty();
|
||||
break;
|
||||
case OpportunityLevel.Provider:
|
||||
metric.Providers.Should().NotBeEmpty()
|
||||
.And.Contain(ct => opportunity.OpportunityLevels.Select(x => x).Contains(ct.Id));
|
||||
metric.Entities.Should().BeEmpty();
|
||||
metric.ServiceLines.Should().BeEmpty();
|
||||
metric.Specialties.Should().BeEmpty();
|
||||
break;
|
||||
}
|
||||
metric.IsBaseline.Should().Be(opportunity.IsBaseline);
|
||||
metric.ConfigurationGuid.Should().NotBe(Guid.Empty);
|
||||
metric.IsSeasonal.Should().Be(opportunity.IsSeasonal);
|
||||
metric.IsBaseline.Should().Be(opportunity.IsBaseline);
|
||||
}
|
||||
public static IEnumerable<TestCaseData> GetEncounterOpportunityMetricTests()
|
||||
{
|
||||
foreach (EncounterGroup encounterGroup in Enum.GetValues(typeof(EncounterGroup)))
|
||||
{
|
||||
if (encounterGroup == EncounterGroup.Both) continue;
|
||||
foreach (OpportunityLevel oppLevel in Enum.GetValues(typeof(OpportunityLevel)))
|
||||
{
|
||||
yield return new TestCaseData(new ENOpportunityDto
|
||||
{
|
||||
ConfigurationGuid = Guid.NewGuid(),
|
||||
Name = "Test Encounter Opportunity",
|
||||
EncounterGroup = (int)encounterGroup,
|
||||
OpportunityLevel = (int)oppLevel,
|
||||
EncounterGroups = new List<string>
|
||||
{
|
||||
"CaseType|CaseType|1"
|
||||
},
|
||||
OpportunityLevels = new List<string>()
|
||||
{
|
||||
"ENT|ENT|1"
|
||||
},
|
||||
IsBaseline = true
|
||||
}).SetName($"TestEncounterOpportunityMetric {encounterGroup} {oppLevel}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+813
@@ -0,0 +1,813 @@
|
||||
using FluentAssertions;
|
||||
using Hangfire;
|
||||
using Hangfire.Common;
|
||||
using Hangfire.States;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Strata.Authorization;
|
||||
using Strata.ContinuousImprovement.Biz.Configuration;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.Encounter;
|
||||
using Strata.ContinuousImprovement.Biz.Encounter.Opportunities;
|
||||
using Strata.ContinuousImprovement.Biz.Encounter.Opportunities.Filters;
|
||||
using Strata.ContinuousImprovement.Biz.Filter;
|
||||
using Strata.ContinuousImprovement.Biz.FiscalMonths;
|
||||
using Strata.ContinuousImprovement.Biz.Generics;
|
||||
using Strata.ContinuousImprovement.Biz.Initiatives;
|
||||
using Strata.ContinuousImprovement.Biz.Notification;
|
||||
using Strata.ContinuousImprovement.Biz.Pagination;
|
||||
using Strata.ContinuousImprovement.Biz.Shared;
|
||||
using Strata.ContinuousImprovement.Biz.Test.Unit.Utilities;
|
||||
using Strata.ContinuousImprovement.JazzEntityFrameworkStub;
|
||||
using Strata.Hangfire.Jazz.Client;
|
||||
using Strata.Hangfire.Jazz.Client.Models;
|
||||
using Strata.Id.Client;
|
||||
using Strata.Schema.Client;
|
||||
using Strata.Schema.Client.Dtos;
|
||||
using Strata.Schema.Client.Dtos.Info;
|
||||
using Strata.SqlTools.Configuration.Common.AsyncFactory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.Encounter.Opportunities
|
||||
{
|
||||
[TestFixture, Category("Unit")]
|
||||
public class ENOpportunityServiceTests
|
||||
{
|
||||
|
||||
private IENOpportunityService _encounterOpportunityService;
|
||||
private Mock<IAsyncDbContextFactory<JazzDbContext>> _dbContextFactoryMock;
|
||||
private Mock<IJazzDbContext> _jazzDbContextMock;
|
||||
private Mock<ISchemaServiceClient> _schemaServiceMock;
|
||||
private Mock<IJazzHangfireServiceClient> _hangfireServiceMock;
|
||||
private Mock<IConfigurationService> _configurationMock;
|
||||
private Mock<IFiscalMonthResolver> _fiscalMonthResolverMock;
|
||||
private Mock<IBackgroundJobClient> _backgroundJobClient;
|
||||
private Mock<IIdServiceClient> _idServiceClient;
|
||||
private Mock<IAuthorizationServiceClient> _authorizationServiceClient;
|
||||
private Mock<IHubContext<NotificationHub, INotificationHub>> _notificationHubContext;
|
||||
private IInitiativeService _initiativeService;
|
||||
private IUpdateFactOpportunitySavingsService _updateFactOpportunitySavingsService;
|
||||
private static readonly ResourceFileExtractor _extractor = new ResourceFileExtractor(".Resource.");
|
||||
private List<Biz.Configuration.Configuration> _configurations;
|
||||
internal static List<Guid> ConfigGuids = new() { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
|
||||
internal static List<string> ConfigNames = new() { "FY2021", "FY2022", "FY2023", "FY2024" };
|
||||
private ScoreDimensionInfoDto _dimension;
|
||||
private List<ScoreHierarchyDto> _hierarchies;
|
||||
private List<HierarchyNodeDto> _hierarchyNodes;
|
||||
private List<FilterHelper> _filterHelpers;
|
||||
private JobEnqueuedResponse _jobResponse;
|
||||
|
||||
[SetUp]
|
||||
public void TestSetUp()
|
||||
{
|
||||
_dbContextFactoryMock = new Mock<IAsyncDbContextFactory<JazzDbContext>>();
|
||||
_jazzDbContextMock = new Mock<IJazzDbContext>();
|
||||
_schemaServiceMock = new Mock<ISchemaServiceClient>();
|
||||
_hangfireServiceMock = new Mock<IJazzHangfireServiceClient>();
|
||||
_configurationMock = new Mock<IConfigurationService>();
|
||||
_fiscalMonthResolverMock = new Mock<IFiscalMonthResolver>();
|
||||
_updateFactOpportunitySavingsService = Mock.Of<IUpdateFactOpportunitySavingsService>();
|
||||
_initiativeService = Mock.Of<IInitiativeService>();
|
||||
_authorizationServiceClient = new Mock<IAuthorizationServiceClient>();
|
||||
_notificationHubContext = new Mock<IHubContext<NotificationHub, INotificationHub>>();
|
||||
_notificationHubContext.Setup(s => s.Clients)
|
||||
.Returns(new Mock<IHubClients<INotificationHub>>().Object);
|
||||
Mock.Get(_updateFactOpportunitySavingsService)
|
||||
.Setup(s => s.UpdateFactOpportunitySavings(It.IsAny<CancellationToken>()));
|
||||
Mock.Get(_initiativeService)
|
||||
.Setup(s => s.DeleteAsync(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(true));
|
||||
_backgroundJobClient = new Mock<IBackgroundJobClient>();
|
||||
_idServiceClient = new Mock<IIdServiceClient>();
|
||||
_encounterOpportunityService = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
|
||||
_configurations = new List<Biz.Configuration.Configuration>
|
||||
{
|
||||
new()
|
||||
{
|
||||
ConfigurationGuid = ConfigGuids[0],
|
||||
Name = ConfigNames.First(),
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
ServiceLineDimensionGuid = Guid.NewGuid()
|
||||
},
|
||||
new()
|
||||
{
|
||||
ConfigurationGuid = ConfigGuids[1],
|
||||
Name = ConfigNames[1],
|
||||
DepartmentRollupGlobalId = "Department",
|
||||
ServiceLineDimensionGuid = Guid.NewGuid()
|
||||
},
|
||||
new()
|
||||
{
|
||||
ConfigurationGuid = ConfigGuids[2],
|
||||
Name = ConfigNames[2],
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
ServiceLineDimensionGuid = Guid.NewGuid()
|
||||
},
|
||||
new()
|
||||
{
|
||||
ConfigurationGuid = ConfigGuids[3],
|
||||
Name = ConfigNames.Last(),
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
ServiceLineDimensionGuid = Guid.NewGuid()
|
||||
}
|
||||
};
|
||||
_dimension = new ScoreDimensionInfoDto
|
||||
{
|
||||
FriendlyName = "test",
|
||||
DimensionGuid = Guid.NewGuid(),
|
||||
DefaultHierarchyGuid = Guid.NewGuid()
|
||||
};
|
||||
_hierarchies = new List<ScoreHierarchyDto>
|
||||
{
|
||||
new ScoreHierarchyDto
|
||||
{
|
||||
FriendlyName = "test",
|
||||
HierarchyGuid = _dimension.DefaultHierarchyGuid
|
||||
}
|
||||
};
|
||||
_hierarchyNodes = new List<HierarchyNodeDto>
|
||||
{
|
||||
new HierarchyNodeDto
|
||||
{
|
||||
Name = "Case Type",
|
||||
Path = "CaseType|CaseType|1"
|
||||
}
|
||||
};
|
||||
_jobResponse = new JobEnqueuedResponse
|
||||
{
|
||||
JobId = Guid.NewGuid()
|
||||
};
|
||||
_filterHelpers = new List<FilterHelper>
|
||||
{
|
||||
new FilterHelper
|
||||
{
|
||||
Id = "CaseType|CaseType|1"
|
||||
}
|
||||
};
|
||||
|
||||
_hangfireServiceMock.Setup(moq =>
|
||||
moq.EnqueueJobAsync(It.IsAny<EnqueueJobDto>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_jobResponse));
|
||||
|
||||
_configurationMock.Setup(moq => moq.GetConfigurationAsync(It.Is<Guid>(c => c == ConfigGuids[0]), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_configurations[0]));
|
||||
_configurationMock.Setup(moq => moq.GetConfigurationAsync(It.Is<Guid>(c => c == ConfigGuids[1]), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_configurations[1]));
|
||||
_configurationMock.Setup(moq => moq.GetConfigurationAsync(It.Is<Guid>(c => c == ConfigGuids[2]), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_configurations[2]));
|
||||
_configurationMock.Setup(moq => moq.GetConfigurationAsync(It.Is<Guid>(c => c == _configurations.Last().ConfigurationGuid), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_configurations.Last()));
|
||||
|
||||
_schemaServiceMock.Setup(moq => moq.GetDimensionByGlobalIdAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_dimension));
|
||||
_schemaServiceMock.Setup(moq => moq.GetDimensionByIdAsync(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_dimension));
|
||||
_schemaServiceMock.Setup(moq => moq.GetScoreHierarchiesByGlobalIdAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_hierarchies.AsEnumerable()));
|
||||
_schemaServiceMock.Setup(moq => moq.GetHierarchyNodesByHierarchyGuidAsync(It.IsAny<Guid>(),
|
||||
It.IsAny<HierarchyNodeParametersDto>(), It.IsAny<List<ExtraFilterDto>>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_hierarchyNodes.AsEnumerable()));
|
||||
_schemaServiceMock.Setup(moq => moq.GetHierarchyNodesFromHierarchyPathsAsync(It.IsAny<Guid>(),
|
||||
It.IsAny<IEnumerable<string>>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(_hierarchyNodes.AsEnumerable()));
|
||||
|
||||
_backgroundJobClient.Setup(moq => moq.Create(It.IsAny<Job>(), It.IsAny<IState>()))
|
||||
.Returns(Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestFirstPage_Sorted_Asc()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var encounterOpportunityService = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
var filters = new ENFilters()
|
||||
{
|
||||
Cases = 0,
|
||||
OpportunityLevels = new List<string>(),
|
||||
EncounterGroups = EncounterGroup.Both,
|
||||
Seasonality = SeasonalityType.WithAndWithout,
|
||||
IdentifiedSavings = 0,
|
||||
ViewVisible = true,
|
||||
ExcludeInitiatives = false,
|
||||
OpportunitySearch = "",
|
||||
|
||||
ConfigurationGuid = JazzEntityFrameworkFactory.CurrentConfigurationGuid
|
||||
};
|
||||
|
||||
var pagingOptions = new PagingOptions("IdentifiedSavings", SortOrder.Asc);
|
||||
|
||||
// act
|
||||
var taskResult = await encounterOpportunityService
|
||||
.GetPagedAsync(pagingOptions, filters, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
taskResult.Data.Should().NotBeNullOrEmpty()
|
||||
.And.AllBeOfType<ENOpportunity>()
|
||||
.And.HaveCountGreaterThan(1);
|
||||
taskResult.Data.First().IdentifiedSavings
|
||||
.Should().BeLessThan(taskResult.Data.Last().IdentifiedSavings);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestFirstPage_Sorted_Desc()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var encounterOpportunityService = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
var filters = new ENFilters()
|
||||
{
|
||||
Cases = 0,
|
||||
OpportunityLevels = new List<string>(),
|
||||
EncounterGroups = EncounterGroup.Both,
|
||||
Seasonality = SeasonalityType.WithAndWithout,
|
||||
IdentifiedSavings = 0,
|
||||
ViewVisible = true,
|
||||
ExcludeInitiatives = false,
|
||||
OpportunitySearch = "",
|
||||
|
||||
ConfigurationGuid = JazzEntityFrameworkFactory.CurrentConfigurationGuid
|
||||
};
|
||||
|
||||
var pagingOptions = new PagingOptions("IdentifiedSavings", SortOrder.Desc);
|
||||
|
||||
// act
|
||||
var taskResult = await encounterOpportunityService
|
||||
.GetPagedAsync(pagingOptions, filters, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
taskResult.Data.Should().NotBeNullOrEmpty()
|
||||
.And.AllBeOfType<ENOpportunity>()
|
||||
.And.HaveCountGreaterThan(1);
|
||||
taskResult.Data.First().IdentifiedSavings
|
||||
.Should().BeGreaterThan(taskResult.Data.Last().IdentifiedSavings);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetFilterData))]
|
||||
public void TestValidateFilters(ENFilters filters)
|
||||
{
|
||||
if (filters == null) return;
|
||||
if (filters.OpportunityLevels.Any())
|
||||
filters.OpportunityLevels.Should()
|
||||
.AllBeOfType<string>()
|
||||
.And.NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetExcelWorkbook()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var opp = framework.ENOpportunities.First();
|
||||
var filters = new ENFilters()
|
||||
{
|
||||
ConfigurationGuid = framework.Configurations.First().ConfigurationGuid,
|
||||
OpportunityLevels = new[] { opp.OpportunityLevel },
|
||||
};
|
||||
var service = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
var wb = await service.ExportAsync(new SortOptions(), filters, CancellationToken.None);
|
||||
#pragma warning disable S125 // Sections of code should not be commented out
|
||||
//wb.SaveAs(System.IO.Path.Combine(@"C:\Git\continuousimprovement\tests\Strata.ContinuousImprovement.Biz.Test.Unit\Resource", "ExcelFilter.xlsx"));
|
||||
#pragma warning restore S125 // Sections of code should not be commented out
|
||||
|
||||
// assert
|
||||
wb.Worksheets.Should().HaveCount(1);
|
||||
var ws = wb.Worksheet(1);
|
||||
ws.Should().NotBeNull();
|
||||
|
||||
var expected = @"Examples.EncounterOpportunity.ExcelFilter.xlsx";
|
||||
using (var expectedStream = _extractor.ReadFileFromResourceToStream(expected))
|
||||
using (var actualStream = new MemoryStream())
|
||||
{
|
||||
wb.SaveAs(actualStream);
|
||||
actualStream.Compare(expectedStream, out var message).Should().BeTrue(message);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetExcelWorkbookNullFilter()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var service = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
var wb = await service.ExportAsync(null, null, CancellationToken.None);
|
||||
#pragma warning disable S125 // Sections of code should not be commented out
|
||||
//wb.SaveAs(System.IO.Path.Combine(@"C:\Git\continuousimprovement\tests\Strata.ContinuousImprovement.Biz.Test.Unit\Resource", "ExcelNullFilter.xlsx"));
|
||||
#pragma warning restore S125 // Sections of code should not be commented out
|
||||
|
||||
// assert
|
||||
wb.Worksheets.Should().HaveCount(1);
|
||||
var ws = wb.Worksheet(1);
|
||||
ws.Should().NotBeNull();
|
||||
|
||||
var expected = @"Examples.EncounterOpportunity.ExcelNullFilter.xlsx";
|
||||
using (var expectedStream = _extractor.ReadFileFromResourceToStream(expected))
|
||||
using (var actualStream = new MemoryStream())
|
||||
{
|
||||
wb.SaveAs(actualStream);
|
||||
actualStream.Compare(expectedStream, out var message).Should().BeTrue(message);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestCreateAsyncCaseTypesOrganization()
|
||||
{
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var opportunity = new ENOpportunityDataModelWithFilters
|
||||
{
|
||||
EncounterGroup = 0,
|
||||
CaseTypes = new List<FilterHelper>
|
||||
{
|
||||
new FilterHelper
|
||||
{
|
||||
Id = "CaseType|CaseType|1"
|
||||
}
|
||||
},
|
||||
EncounterOpportunityLevel = OpportunityLevel.Organization
|
||||
};
|
||||
opportunity.ConfigurationGuid = framework.Configurations.FirstOrDefault().ConfigurationGuid;
|
||||
var service = new ENOpportunityService(framework, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
|
||||
var results = await service.CreateAsync(opportunity.MapToDataModel(null), Guid.Empty, true, CancellationToken.None);
|
||||
results.Should().NotBe(Guid.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestCreateAsyncAllCaseTypesOrganization()
|
||||
{
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var opportunity = new ENOpportunityDataModelWithFilters
|
||||
{
|
||||
EncounterGroup = 0,
|
||||
EncounterOpportunityLevel = OpportunityLevel.Organization
|
||||
};
|
||||
opportunity.ConfigurationGuid = framework.Configurations.FirstOrDefault().ConfigurationGuid;
|
||||
var service = new ENOpportunityService(framework, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var results = await service.CreateAsync(opportunity.MapToDataModel(null), Guid.Empty, true, CancellationToken.None);
|
||||
results.Should().NotBe(Guid.Empty);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetENOpportunityDataModel))]
|
||||
public async Task TestCreateAsync(ENOpportunityDataModelWithFilters opportunity)
|
||||
{
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
opportunity.ConfigurationGuid = framework.Configurations.FirstOrDefault().ConfigurationGuid;
|
||||
var service = new ENOpportunityService(framework, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var results = await service.CreateAsync(opportunity.MapToDataModel(null), Guid.Empty, true, CancellationToken.None);
|
||||
results.Should().NotBe(Guid.Empty);
|
||||
}
|
||||
|
||||
[Test, Ignore("Problem moq'ing GetEntityNodes")]
|
||||
public async Task TestCreateAsyncAllCaseTypesAllEntities()
|
||||
{
|
||||
var serviceMock = new Mock<ENOpportunityService>(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var service = serviceMock.Object;
|
||||
var opportunity = new ENOpportunityDataModelWithFilters
|
||||
{
|
||||
EncounterGroup = 0,
|
||||
EncounterOpportunityLevel = OpportunityLevel.Entity
|
||||
};
|
||||
var results = await service.CreateAsync(opportunity.MapToDataModel(null), Guid.Empty, true, CancellationToken.None);
|
||||
results.Should().NotBe(Guid.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetEntityNodes()
|
||||
{
|
||||
var service = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var configuration = new Biz.Configuration.Configuration
|
||||
{
|
||||
DepartmentRollupGlobalId = ""
|
||||
};
|
||||
|
||||
var results = await service.GetEntityNodes(configuration, CancellationToken.None);
|
||||
results.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetServiceLineNodesBySg2()
|
||||
{
|
||||
var service = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var configuration = new Biz.Configuration.Configuration
|
||||
{
|
||||
ServiceLineDimensionGuid = Guid.Empty
|
||||
};
|
||||
|
||||
var results = await service.GetServiceLineNodes(configuration, new List<string>(), CancellationToken.None);
|
||||
results.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetServiceLineNodes()
|
||||
{
|
||||
var service = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var configuration = new Biz.Configuration.Configuration
|
||||
{
|
||||
ServiceLineDimensionGuid = Guid.NewGuid()
|
||||
};
|
||||
|
||||
var results = await service.GetServiceLineNodes(configuration, new List<string>(), CancellationToken.None);
|
||||
results.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetNodesByGlobalId()
|
||||
{
|
||||
var service = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var results = await service.GetNodesByGlobalId("entity", CancellationToken.None);
|
||||
results.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestGetNodesByHierarchyGuid()
|
||||
{
|
||||
var service = new ENOpportunityService(_dbContextFactoryMock.Object, null, null,
|
||||
_schemaServiceMock.Object, _hangfireServiceMock.Object, _configurationMock.Object, _fiscalMonthResolverMock.Object,
|
||||
_initiativeService, _updateFactOpportunitySavingsService, _backgroundJobClient.Object, _idServiceClient.Object, _notificationHubContext.Object, _authorizationServiceClient.Object);
|
||||
var results = await service.GetNodesByHierarchyGuid(Guid.NewGuid(), CancellationToken.None);
|
||||
results.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestSetHidden()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var opportunities = framework.ENOpportunities;
|
||||
var opportunity = opportunities.First(vo => !vo.IsHidden);
|
||||
var isHidden = opportunity.IsHidden;
|
||||
var service = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
await service.SetHiddenAsync(opportunity.OpportunityGuid, !isHidden, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
var result = await service.GetById(opportunity.OpportunityGuid, CancellationToken.None);
|
||||
result.IsHidden.Should().Be(!isHidden);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworksWithCancellation))]
|
||||
public async Task TestGetFilterOptionsAsync(JazzEntityFrameworkFactory jazzEntityFrameworkFactory, CancellationToken cancellationToken)
|
||||
{
|
||||
// arrange
|
||||
var opportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
try
|
||||
{
|
||||
// act
|
||||
var taskResult = await opportunityService
|
||||
.GetFilterOptionsAsync(new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345"), cancellationToken);
|
||||
|
||||
// assert
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName))
|
||||
{
|
||||
taskResult.Should().BeNull();
|
||||
return;
|
||||
}
|
||||
taskResult.Should()
|
||||
.BeOfType<ENFilterOptions>()
|
||||
.And.NotBeNull();
|
||||
taskResult.OpportunityLevels.Should().AllBeOfType<FilterMember>().And.NotBeNullOrEmpty()
|
||||
.And.NotContain(cd => string.IsNullOrEmpty(cd.Id))
|
||||
.And.NotContain(cd => string.IsNullOrEmpty(cd.Text));
|
||||
}
|
||||
catch (NotImplementedException nie)
|
||||
{
|
||||
nie.Should().BeOfType<NotImplementedException>();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.Should().BeOfType<OperationCanceledException>();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworksWithCancellation))]
|
||||
public async Task TestSetHiddenAsync(JazzEntityFrameworkFactory jazzEntityFrameworkFactory, CancellationToken cancellationToken)
|
||||
{
|
||||
// arrange
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
try
|
||||
{
|
||||
var opportunities = encounterOpportunityService.GetAllAsync(cancellationToken).Result;
|
||||
var opportunity = opportunities.FirstOrDefault(o => o.IsHidden);
|
||||
if (opportunity == null) return;
|
||||
var isHidden = opportunity.IsHidden;
|
||||
|
||||
//act
|
||||
await encounterOpportunityService.SetHiddenAsync(opportunity.OpportunityGuid, !isHidden,
|
||||
|
||||
cancellationToken);
|
||||
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName)) return;
|
||||
|
||||
var result = encounterOpportunityService.GetById(opportunity.OpportunityGuid, cancellationToken).Result;
|
||||
|
||||
result.IsHidden.Should().Be(!isHidden);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
switch (e.GetType().Name)
|
||||
{
|
||||
case "AggregateException":
|
||||
case "OperationCanceledException":
|
||||
return;
|
||||
}
|
||||
e.Should().NotBeOfType<Exception>();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworksWithCancellation))]
|
||||
public async Task TestSetHiddenAsync_NoOpportunity(JazzEntityFrameworkFactory jazzEntityFrameworkFactory, CancellationToken cancellationToken)
|
||||
{
|
||||
// arrange
|
||||
var opportunity = jazzEntityFrameworkFactory.ENOpportunities.FirstOrDefault(o => o.IsHidden);
|
||||
if (opportunity == null) return;
|
||||
var isHidden = opportunity.IsHidden;
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
try
|
||||
{
|
||||
// act
|
||||
await encounterOpportunityService.SetHiddenAsync(Guid.Empty, !isHidden,
|
||||
cancellationToken);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.Should().BeOfType<OperationCanceledException>();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworksWithCancellation))]
|
||||
public async Task TestSetNoteAsync(JazzEntityFrameworkFactory jazzEntityFrameworkFactory, CancellationToken cancellationToken)
|
||||
{
|
||||
// arrange
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
try
|
||||
{
|
||||
var opportunities = encounterOpportunityService.GetAllAsync(cancellationToken).Result;
|
||||
|
||||
var opportunity = opportunities.FirstOrDefault(o => o.Note == string.Empty);
|
||||
|
||||
if (opportunity == null) return;
|
||||
|
||||
var note = "new test note";
|
||||
// act
|
||||
await encounterOpportunityService.SetNoteAsync(opportunity.OpportunityGuid, note,
|
||||
CancellationToken.None);
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName)) return;
|
||||
var result = encounterOpportunityService.GetById(opportunity.OpportunityGuid, cancellationToken).Result;
|
||||
result.Note.Should().Be(note);
|
||||
|
||||
// assert
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
switch (e.GetType().Name)
|
||||
{
|
||||
case "AggregateException":
|
||||
case "OperationCanceledException":
|
||||
return;
|
||||
}
|
||||
e.Should().NotBeOfType<Exception>();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestSetNote()
|
||||
{
|
||||
// arrange
|
||||
var framework = new JazzEntityFrameworkFactory();
|
||||
await framework.CreateDbContextAsync(CancellationToken.None);
|
||||
var opportunities = framework.ENOpportunities;
|
||||
var opportunity = opportunities.First(vo => string.IsNullOrEmpty(vo.Note));
|
||||
var note = opportunity.Note;
|
||||
var expected = "Now is the time for all good engineers to write great code!";
|
||||
var service = new ENOpportunityService(framework, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
await service.SetNoteAsync(opportunity.OpportunityGuid, expected, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
var result = await service.GetById(opportunity.OpportunityGuid, CancellationToken.None);
|
||||
result.Note.Should().NotBeNullOrEmpty()
|
||||
.And.NotBe(note)
|
||||
.And.Be(expected);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworksWithCancellation))]
|
||||
public async Task TestSetNoteAsync_NoOpportunity(JazzEntityFrameworkFactory jazzEntityFrameworkFactory, CancellationToken cancellationToken)
|
||||
{
|
||||
// arrange
|
||||
var opportunity = jazzEntityFrameworkFactory.ENOpportunities.FirstOrDefault(o => o.Note == string.Empty);
|
||||
if (opportunity == null) return;
|
||||
var note = "new test note";
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
try
|
||||
{
|
||||
// act
|
||||
await encounterOpportunityService.SetNoteAsync(Guid.Empty, note, cancellationToken);
|
||||
|
||||
// assert
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.Should().BeOfType<OperationCanceledException>();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworks))]
|
||||
public async Task TestGetAllAsync(JazzEntityFrameworkFactory jazzEntityFrameworkFactory)
|
||||
{
|
||||
// arrange
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
var taskResult = await encounterOpportunityService.GetAllAsync(CancellationToken.None);
|
||||
|
||||
// assert
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName))
|
||||
{
|
||||
taskResult.Should().BeNullOrEmpty();
|
||||
}
|
||||
else
|
||||
{
|
||||
taskResult.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworks))]
|
||||
public async Task TestGetById(JazzEntityFrameworkFactory jazzEntityFrameworkFactory)
|
||||
{
|
||||
// arrange
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
var tempResult = await encounterOpportunityService.GetAllAsync(CancellationToken.None);
|
||||
var taskResult =
|
||||
await encounterOpportunityService.GetById(tempResult.FirstOrDefault()?.OpportunityGuid ?? Guid.Empty, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName))
|
||||
{
|
||||
taskResult.Should().BeNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
taskResult.Should().NotBeNull()
|
||||
.And.BeOfType<ENOpportunity>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(JazzEntityFrameworkFactory), nameof(JazzEntityFrameworkFactory.GetFrameworks))]
|
||||
public async Task TestGetByIds(JazzEntityFrameworkFactory jazzEntityFrameworkFactory)
|
||||
{
|
||||
// arrange
|
||||
var encounterOpportunityService = new ENOpportunityService(jazzEntityFrameworkFactory, null, null, _initiativeService, _updateFactOpportunitySavingsService);
|
||||
|
||||
// act
|
||||
var tempResult = await encounterOpportunityService.GetAllAsync(CancellationToken.None);
|
||||
var ids = tempResult.Select(o => o.OpportunityGuid);
|
||||
var taskResult = await encounterOpportunityService.GetByIds(ids, CancellationToken.None);
|
||||
|
||||
// assert
|
||||
if (string.IsNullOrEmpty(jazzEntityFrameworkFactory.TestName))
|
||||
{
|
||||
taskResult.Should().BeNullOrEmpty();
|
||||
}
|
||||
else
|
||||
{
|
||||
taskResult.Should().NotBeNullOrEmpty()
|
||||
.And.AllBeOfType<ENOpportunity>()
|
||||
.And.HaveCount(ids.Count());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TestTearDown()
|
||||
{
|
||||
// Method intentionally left empty.
|
||||
}
|
||||
|
||||
#region TestCaseData
|
||||
|
||||
public static IEnumerable<TestCaseData> GetFilterData()
|
||||
{
|
||||
yield return new TestCaseData(new ENFilters { ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName("No Filters");
|
||||
yield return new TestCaseData(new ENFilters { ViewVisible = true, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName("View Visible");
|
||||
yield return new TestCaseData(new ENFilters { ViewVisible = false, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName("Not View Visible");
|
||||
yield return new TestCaseData(new ENFilters { IdentifiedSavings = 1999, ViewVisible = true, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName(
|
||||
"By Identified Savings");
|
||||
yield return new TestCaseData(new ENFilters { IdentifiedSavings = 999, ViewVisible = false, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName(
|
||||
"By Identified Savings Not ViewVisible");
|
||||
yield return new TestCaseData(new ENFilters { OpportunityLevels = new[] { "Entity" }, ViewVisible = true, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") })
|
||||
.SetName("By OpportunityLevels");
|
||||
yield return new TestCaseData(new ENFilters { OpportunityLevels = new[] { "Provider" }, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345"), ViewVisible = false })
|
||||
.SetName("By OpportunityLevels Not ViewVisible");
|
||||
yield return new TestCaseData(new ENFilters { EncounterGroups = EncounterGroup.CaseType, ViewVisible = true, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") })
|
||||
.SetName("By EncounterGroups");
|
||||
yield return new TestCaseData(new ENFilters { EncounterGroups = EncounterGroup.PatientPopulation, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345"), ViewVisible = false })
|
||||
.SetName("By EncounterGroups Not ViewVisible");
|
||||
yield return new TestCaseData(new ENFilters { Seasonality = SeasonalityType.With, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") })
|
||||
.SetName("By Seaonality");
|
||||
yield return new TestCaseData(new ENFilters { OpportunitySearch = "EN - 101", ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName("Search By Id");
|
||||
yield return new TestCaseData(new ENFilters { ExcludeInitiatives = true, ConfigurationGuid = new Guid("e96abe3e-1526-43ca-815e-ee30c5b34345") }).SetName("Exclude Opportunities with Initiatives");
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> GetENOpportunityDataModel()
|
||||
{
|
||||
return from configGuid in ConfigGuids
|
||||
from EncounterGroup encounterGroup in Enum.GetValues(typeof(EncounterGroup))
|
||||
where encounterGroup != EncounterGroup.Both
|
||||
from OpportunityLevel encounterOpportunityLevel in Enum.GetValues(typeof(OpportunityLevel))
|
||||
from encounterGroups in new[] { true, false }
|
||||
from opportunityLevels in new[] { true, false }
|
||||
select new TestCaseData(new ENOpportunityDataModelWithFilters
|
||||
{
|
||||
ConfigurationGuid = configGuid,
|
||||
EncounterGroup = (int)encounterGroup,
|
||||
EncounterOpportunityLevel = encounterOpportunityLevel,
|
||||
CaseTypes = encounterGroup == EncounterGroup.CaseType
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new() {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>(),
|
||||
PatientPopulations = encounterGroup == EncounterGroup.PatientPopulation
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new () {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>(),
|
||||
Entities = encounterOpportunityLevel == OpportunityLevel.Entity
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new () {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>(),
|
||||
ServiceLines = encounterOpportunityLevel == OpportunityLevel.ServiceLine
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new () {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>(),
|
||||
Specialties = encounterOpportunityLevel == OpportunityLevel.Specialty
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new () {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>(),
|
||||
Providers = encounterOpportunityLevel == OpportunityLevel.Provider
|
||||
? new List<FilterHelper>
|
||||
{
|
||||
new () {Id = "Id"}
|
||||
}
|
||||
: new List<FilterHelper>()
|
||||
}).SetName($"{nameof(TestCreateAsync)} {ConfigNames[ConfigGuids.IndexOf(configGuid)]} IsUsingCustomEntityDim: {ConfigGuids.IndexOf(configGuid) == 1} IsUsingSg2: {ConfigGuids.IndexOf(configGuid) == 3} {encounterGroup} {encounterOpportunityLevel}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user