Template
151 lines
6.6 KiB
C#
151 lines
6.6 KiB
C#
using FluentAssertions;
|
|
using RichardSzalay.MockHttp;
|
|
using Strata.DecisionSupport.Models.Encounters;
|
|
using Strata.DecisionSupport.Models.Jazz;
|
|
using Strata.DecisionSupport.Models.Queries;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Json;
|
|
using System.Text.Json;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Strata.ContinuousImprovement.Client.Test.Unit
|
|
{
|
|
[TestFixture, Category("Unit"), Category("Client"), Ignore("needs attention")]
|
|
public class ClientTests
|
|
{
|
|
public Uri HtpUrl { get; set; }
|
|
public Uri Url { get; set; }
|
|
|
|
[SetUp]
|
|
public void TestSetup()
|
|
{
|
|
HtpUrl = new Uri("https://continuousimprovement/");
|
|
Url = new Uri(HtpUrl, "api/v1/encounters");
|
|
}
|
|
|
|
[TestCaseSource(nameof(TestClientCases))]
|
|
public async Task TestClient(EncounterQueryInfo queryInfo, List<IJazzEncounterInfo> response)
|
|
{
|
|
var httpHandler = new MockHttpMessageHandler();
|
|
httpHandler.When(HttpMethod.Post, Url.ToString())
|
|
.WithContent(JsonSerializer.Serialize(queryInfo,
|
|
options: new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }))
|
|
.Respond(HttpStatusCode.OK, JsonContent.Create(response));
|
|
var httpClient = new HttpClient(httpHandler)
|
|
{
|
|
BaseAddress = HtpUrl
|
|
};
|
|
|
|
var ciService = new ContinuousImprovementService(httpClient);
|
|
var result = await ciService.DecisionSupportMsdrgEncounterInfo(queryInfo, CancellationToken.None);
|
|
|
|
Assert.That(result, Is.Not.Null.And.Not.Empty);
|
|
}
|
|
|
|
public static IEnumerable<TestCaseData> TestClientCases()
|
|
{
|
|
yield return new TestCaseData(
|
|
new EncounterQueryInfo(Strata.DecisionSupport.Models.Queries.CaseTypeCategory.MSDRG, 207, DateTime.Now, DateTime.Now, "", Guid.NewGuid(), 24, new List<int> { 2 }),
|
|
new List<IJazzEncounterInfo> { new MSDRGEncounterInfo() })
|
|
.SetName("TestClient - EncounterQueryInfo constructor Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.MSDRG,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new MSDRGEncounterInfo() })
|
|
.SetName("TestClient - MSDRG Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.MSDRG,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "Location",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new MSDRGEncounterInfo() })
|
|
.SetName("TestClient - MSDRG Location Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.MSDRG,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "Department Rollup 1",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new MSDRGEncounterInfo() })
|
|
.SetName("TestClient - MSDRG Department Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.APRDRG,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new APRDRGEncounterInfo() })
|
|
.SetName("TestClient - APRDRG Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.CPTCode,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new CPTCodeEncounterInfo() })
|
|
.SetName("TestClient - CPTCode Request");
|
|
yield return new TestCaseData(new EncounterQueryInfo
|
|
{
|
|
CaseTypeCategory = CaseTypeCategory.PatientPopulation,
|
|
CaseTypeFamilyId = 207,
|
|
DepartmentRollupGlobalId = "",
|
|
ServiceLineGuid = Guid.NewGuid(),
|
|
StartDate = DateTime.Now,
|
|
EndDate = DateTime.Now,
|
|
EntityIDs = new List<int> { 2 }
|
|
},
|
|
new List<IJazzEncounterInfo> { new PatientPopulationEncounterInfo() })
|
|
.SetName("TestClient - Patient Population Request");
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestClientError()
|
|
{
|
|
var httpHandler = new MockHttpMessageHandler();
|
|
var queryInfo = new Strata.DecisionSupport.Biz.Parameters.EncounterQueryInfo(Strata.DecisionSupport.Models.Queries.CaseTypeCategory.MSDRG, 207, DateTime.Now, DateTime.Now, "", Guid.NewGuid(), 24, new List<int>());
|
|
httpHandler.When(HttpMethod.Post, Url.ToString())
|
|
.WithContent(JsonSerializer.Serialize(queryInfo,
|
|
options: new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }))
|
|
.Respond(HttpStatusCode.InternalServerError);
|
|
var httpClient = new HttpClient(httpHandler)
|
|
{
|
|
BaseAddress = HtpUrl
|
|
};
|
|
|
|
var ciService = new ContinuousImprovementService(httpClient);
|
|
Func<Task> action = ciService.Awaiting(x => x.DecisionSupportMsdrgEncounterInfo(queryInfo, CancellationToken.None));
|
|
await action.Should()
|
|
.ThrowAsync<ArgumentNullException>()
|
|
.WithMessage("Value cannot be null. (Parameter 'encounterInfo')");
|
|
}
|
|
|
|
}
|
|
} |