Template
chore: deploy initial code base
This commit is contained in:
+201
@@ -0,0 +1,201 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Strata.ContinuousImprovement.Biz.Configuration;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts.Snowflake;
|
||||
using Strata.ContinuousImprovement.Biz.QualityVariation.QVI;
|
||||
using CIConfiguration = Strata.ContinuousImprovement.Biz.Configuration.Configuration;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.QualityVariation.QVI
|
||||
{
|
||||
[TestFixture, Category("Unit")]
|
||||
public class NonQviSavingsServiceTest
|
||||
{
|
||||
private Mock<ISnowflakeDatabaseContext> _snowflakeDatabaseContextMock;
|
||||
private Mock<IConfigurationService> _configurationServiceMock;
|
||||
private Mock<ILogger<NonQviSavingsService>> _loggerMock;
|
||||
private NonQviSavingsService _service;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_snowflakeDatabaseContextMock = new Mock<ISnowflakeDatabaseContext>();
|
||||
_configurationServiceMock = new Mock<IConfigurationService>();
|
||||
_loggerMock = new Mock<ILogger<NonQviSavingsService>>();
|
||||
|
||||
_service = new NonQviSavingsService(
|
||||
_snowflakeDatabaseContextMock.Object,
|
||||
_configurationServiceMock.Object,
|
||||
_loggerMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenNoEntityIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = string.Empty, SourceSystemIdsCSV = "1" });
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenNoSourceSystemIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = "1", SourceSystemIdsCSV = string.Empty });
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenEntitiesExist_QueriesSnowflake()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var expected = new[] { new NonQviCaseTypeFamilyInfo { CaseTypeFamilyId = 10, CaseCount = 3 } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration
|
||||
{
|
||||
EntityIdsCSV = "1",
|
||||
SourceSystemIdsCSV = "1",
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
QualityVariationEndDate = new DateTime(2024, 12, 31)
|
||||
});
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<NonQviCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(NonQviSavingsService.GetCaseTypeFamilyInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(NonQviSavingsService.GetCaseTypeFamilyInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenNoEntityIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = string.Empty, SourceSystemIdsCSV = "1" });
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenNoSourceSystemIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = "1", SourceSystemIdsCSV = string.Empty });
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenEntitiesExist_QueriesSnowflake()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var expected = new[] { new NonQviDrgTypeInfo { DrgType = "MS" } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration
|
||||
{
|
||||
EntityIdsCSV = "1",
|
||||
SourceSystemIdsCSV = "1",
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
QualityVariationEndDate = new DateTime(2024, 12, 31)
|
||||
});
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<NonQviDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(NonQviSavingsService.GetDrgTypeInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<NonQviDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(NonQviSavingsService.GetDrgTypeInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenConfigurationThrows_Rethrows()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new InvalidOperationException("boom"));
|
||||
|
||||
var action = async () => await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
await action.Should().ThrowAsync<InvalidOperationException>();
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Strata.ContinuousImprovement.Biz.Configuration;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts.Snowflake;
|
||||
using Strata.ContinuousImprovement.Biz.QualityVariation.QVI;
|
||||
using Strata.SqlTools.Configuration.Common.AsyncFactory;
|
||||
using CIConfiguration = Strata.ContinuousImprovement.Biz.Configuration.Configuration;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.QualityVariation.QVI
|
||||
{
|
||||
[TestFixture, Category("Unit")]
|
||||
public class QviEncounterServiceTest
|
||||
{
|
||||
private Mock<ISnowflakeDatabaseContext> _snowflakeDatabaseContextMock;
|
||||
private Mock<IConfigurationService> _configurationServiceMock;
|
||||
private Mock<IAsyncDbContextFactory<JazzDbContext>> _dbContextFactoryMock;
|
||||
private Mock<ILogger<QviEncounterService>> _loggerMock;
|
||||
private QviEncounterService _service;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_snowflakeDatabaseContextMock = new Mock<ISnowflakeDatabaseContext>();
|
||||
_configurationServiceMock = new Mock<IConfigurationService>();
|
||||
_dbContextFactoryMock = new Mock<IAsyncDbContextFactory<JazzDbContext>>();
|
||||
_loggerMock = new Mock<ILogger<QviEncounterService>>();
|
||||
|
||||
_service = new QviEncounterService(
|
||||
_snowflakeDatabaseContextMock.Object,
|
||||
_configurationServiceMock.Object,
|
||||
_dbContextFactoryMock.Object,
|
||||
_loggerMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterInfoAsync_WhenNoEntityIds_ReturnsEmptyAndSkipsDatabase()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = string.Empty, SourceSystemIdsCSV = "1" });
|
||||
|
||||
var result = await _service.GetEncounterInfoAsync(configurationGuid, DateTime.UtcNow, DateTime.UtcNow, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_dbContextFactoryMock.Verify(f => f.CreateDbContextAsync(It.IsAny<CancellationToken>()), Times.Never);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<EncounterInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterInfoAsync_WhenNoSourceSystemIds_ReturnsEmptyAndSkipsDatabase()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = "1", SourceSystemIdsCSV = string.Empty });
|
||||
|
||||
var result = await _service.GetEncounterInfoAsync(configurationGuid, DateTime.UtcNow, DateTime.UtcNow, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_dbContextFactoryMock.Verify(f => f.CreateDbContextAsync(It.IsAny<CancellationToken>()), Times.Never);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<EncounterInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterInfoAsync_WhenConfigurationThrows_Rethrows()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new InvalidOperationException("boom"));
|
||||
|
||||
var action = async () => await _service.GetEncounterInfoAsync(configurationGuid, DateTime.UtcNow, DateTime.UtcNow, CancellationToken.None);
|
||||
|
||||
await action.Should().ThrowAsync<InvalidOperationException>();
|
||||
}
|
||||
}
|
||||
}
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Strata.ContinuousImprovement.Biz.Configuration;
|
||||
using Strata.ContinuousImprovement.Biz.DbContexts.Snowflake;
|
||||
using Strata.ContinuousImprovement.Biz.QualityVariation.QVI;
|
||||
using CIConfiguration = Strata.ContinuousImprovement.Biz.Configuration.Configuration;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.ContinuousImprovement.Biz.Test.Unit.QualityVariation.QVI
|
||||
{
|
||||
[TestFixture, Category("Unit")]
|
||||
public class QviLineItemSavingsServiceTest
|
||||
{
|
||||
private Mock<ISnowflakeDatabaseContext> _snowflakeDatabaseContextMock;
|
||||
private Mock<IConfigurationService> _configurationServiceMock;
|
||||
private Mock<ILogger<QviLineItemSavingsService>> _loggerMock;
|
||||
private QviLineItemSavingsService _service;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_snowflakeDatabaseContextMock = new Mock<ISnowflakeDatabaseContext>();
|
||||
_configurationServiceMock = new Mock<IConfigurationService>();
|
||||
_loggerMock = new Mock<ILogger<QviLineItemSavingsService>>();
|
||||
|
||||
_service = new QviLineItemSavingsService(
|
||||
_snowflakeDatabaseContextMock.Object,
|
||||
_configurationServiceMock.Object,
|
||||
_loggerMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenNoEntityIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = string.Empty, SourceSystemIdsCSV = "1" });
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenNoSourceSystemIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = "1", SourceSystemIdsCSV = string.Empty });
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetCaseTypeFamilyInfoAsync_WhenEntitiesExist_QueriesSnowflake()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var expected = new[] { new QviLineItemCaseTypeFamilyInfo { QualityVariationEventId = 42, CaseTypeFamilyId = 7 } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration
|
||||
{
|
||||
EntityIdsCSV = "1",
|
||||
SourceSystemIdsCSV = "1",
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
QualityVariationEndDate = new DateTime(2024, 12, 31)
|
||||
});
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<QviLineItemCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetCaseTypeFamilyInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetCaseTypeFamilyInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemCaseTypeFamilyInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetCaseTypeFamilyInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenNoEntityIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = string.Empty, SourceSystemIdsCSV = "1" });
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenNoSourceSystemIds_ReturnsEmpty()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration { EntityIdsCSV = "1", SourceSystemIdsCSV = string.Empty });
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEmpty();
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetDrgTypeInfoAsync_WhenEntitiesExist_QueriesSnowflake()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var expected = new[] { new QviLineItemDrgTypeInfo { DrgType = "APR" } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration
|
||||
{
|
||||
EntityIdsCSV = "1",
|
||||
SourceSystemIdsCSV = "1",
|
||||
DepartmentRollupGlobalId = string.Empty,
|
||||
QualityVariationEndDate = new DateTime(2024, 12, 31)
|
||||
});
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<QviLineItemDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetDrgTypeInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetDrgTypeInfoAsync(configurationGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemDrgTypeInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetDrgTypeInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterSavingInfoAsync_UsesConfigurationGuidParameter()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var expected = new[] { new QviLineItemEncounterSavingInfo { EncounterRecordNumber = "enc-1" } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration());
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<QviLineItemEncounterSavingInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetEncounterSavingInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetEncounterSavingInfoAsync(configurationGuid, null, null, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
_snowflakeDatabaseContextMock.Verify(
|
||||
s => s.QueryAsync<QviLineItemEncounterSavingInfo>(
|
||||
It.IsAny<string>(),
|
||||
nameof(QviLineItemSavingsService.GetEncounterSavingInfoAsync),
|
||||
It.Is<object>(o =>
|
||||
o.GetType().GetProperty("ConfigurationGUID") != null &&
|
||||
(Guid)o.GetType().GetProperty("ConfigurationGUID").GetValue(o)! == configurationGuid),
|
||||
It.IsAny<TimeSpan>()),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterSavingInfoAsync_WhenOpportunityGuidAndIsBaselineProvided_FiltersQuery()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
var opportunityGuid = Guid.NewGuid();
|
||||
var expected = new[] { new QviLineItemEncounterSavingInfo { EncounterRecordNumber = "enc-1" } };
|
||||
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration());
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<QviLineItemEncounterSavingInfo>(
|
||||
It.Is<string>(q => q.Contains(":OpportunityGUID") && q.Contains(":IsBaseline")),
|
||||
nameof(QviLineItemSavingsService.GetEncounterSavingInfoAsync),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ReturnsAsync(expected);
|
||||
|
||||
var result = await _service.GetEncounterSavingInfoAsync(configurationGuid, opportunityGuid, true, CancellationToken.None);
|
||||
|
||||
result.Should().BeEquivalentTo(expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEncounterSavingInfoAsync_WhenSnowflakeThrows_Rethrows()
|
||||
{
|
||||
var configurationGuid = Guid.NewGuid();
|
||||
_configurationServiceMock
|
||||
.Setup(s => s.GetConfigurationAsync(configurationGuid, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new CIConfiguration());
|
||||
|
||||
_snowflakeDatabaseContextMock
|
||||
.Setup(s => s.QueryAsync<QviLineItemEncounterSavingInfo>(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<object>(),
|
||||
It.IsAny<TimeSpan>()))
|
||||
.ThrowsAsync(new InvalidOperationException("boom"));
|
||||
|
||||
var action = async () => await _service.GetEncounterSavingInfoAsync(configurationGuid, null, null, CancellationToken.None);
|
||||
|
||||
await action.Should().ThrowAsync<InvalidOperationException>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user