Template
chore: deploy initial code base
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Snowflake.Data.Client;
|
||||
using Strata.DecisionSupport.Biz.Services;
|
||||
using Strata.DecisionSupport.Biz.Snowflake;
|
||||
using Strata.Schema.Client;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Strata.DecisionSupport.Biz.Test.Integration
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
[SetUpFixture]
|
||||
public class IntegrationTestBase
|
||||
{
|
||||
protected VerifySettings verifySettings;
|
||||
protected VerifySettings verifyErrorSettings;
|
||||
|
||||
protected readonly Guid GmAutomationDatabase = new("cda90beb-6c2e-41af-9083-857a09fe8183"); // GM Automation (Refreshed)
|
||||
protected Guid VariationOpportunityGuid { get; set; }
|
||||
protected Guid LOSOpportunityGuid { get; set; }
|
||||
protected ISnowflakeDatabaseContext _databaseContext;
|
||||
protected IEncounterQueryService _encounterQueryService;
|
||||
#pragma warning disable NUnit1032
|
||||
protected IServiceProvider _serviceProvider; //used to grab any necessary DI objects
|
||||
#pragma warning restore NUnit1032
|
||||
protected ILogger<IntegrationTestBase>? logger;
|
||||
|
||||
|
||||
//When running locally sets the profile to the data wrangler profile so you have access to resources
|
||||
[OneTimeSetUp]
|
||||
public async Task SetDatabaseContext()
|
||||
{
|
||||
#if DEBUG
|
||||
Environment.SetEnvironmentVariable("AWS_Profile", "sdt-continuous-improvement-service-role");
|
||||
#endif
|
||||
var services = ServiceCollectionFactory.Create();
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
var sfConnBuilderFactory = _serviceProvider.GetRequiredService<ISnowflakeDatabaseContextFactory>();
|
||||
_databaseContext = sfConnBuilderFactory.Create($"{GmAutomationDatabase:N}");
|
||||
verifySettings = TestExtensions.TestSettings();
|
||||
verifyErrorSettings = TestExtensions.TestSettings();
|
||||
verifyErrorSettings.UseDirectory("errorSnapshots");
|
||||
var schemaServiceClient = Mock.Of<ISchemaServiceClient>();
|
||||
_encounterQueryService = new EncounterQueryService(_databaseContext, schemaServiceClient);
|
||||
try
|
||||
{
|
||||
var query = @"select OpportunityGuid from cci.VariationOpportunity where CostDriver = 'Pharmacy' order by Savings DESC limit 1";
|
||||
var opportunityGuid = await _databaseContext.ExecuteScalarAsync<string>(query);
|
||||
VariationOpportunityGuid = new Guid(opportunityGuid ?? Guid.NewGuid().ToString());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
try
|
||||
{
|
||||
var query = @"select OpportunityGuid from cci.VariationOpportunity where CostDriver = 'LOS' order by Savings DESC limit 1";
|
||||
var opportunityGuid = await _databaseContext.ExecuteScalarAsync<string>(query);
|
||||
LOSOpportunityGuid = new Guid(opportunityGuid ?? Guid.NewGuid().ToString());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual async Task QueryTest<T, TI>(TI queryInfo)
|
||||
where TI : class
|
||||
where T : class
|
||||
{
|
||||
var query = Query(queryInfo);
|
||||
if (string.IsNullOrEmpty(query)) { return; }
|
||||
try
|
||||
{
|
||||
var result = await _databaseContext
|
||||
.QueryAsync<T>(query, nameof(QueryTest), CancellationToken.None);
|
||||
await Verifier.Verify(result, verifySettings)
|
||||
.UseFileName(TestContext.CurrentContext.TestName(nameof(result)));
|
||||
}
|
||||
catch (SnowflakeDbException dbex)
|
||||
{
|
||||
// ILB
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string Query<T>(T queryInfo)
|
||||
where T : class
|
||||
=> "";
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
// _serviceProvider.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user