Files
2026-06-23 11:26:55 -05:00

44 lines
1.7 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Strata.SnowflakeLib;
using Strata.Stratasphere.Biz.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Strata.Stratasphere.Biz.IntegrationTests.Standards.IntegrationTests
{
[SetUpFixture]
public abstract class IntegrationTestBase
{
protected readonly Guid _DatabaseGuid = new Guid("00732a12-e90f-49bd-9d9d-3ff43ec7c750"); //gm working small
protected StrataSnowflakeConnection _dbSnowflakeConnection;
protected IServiceProvider _serviceProvider; //used to grab any necessary DI objects
public IntegrationTestBase()
{
}
//When running locally sets the profile to the data wrangler profile so you have access to resources
[OneTimeSetUp]
public void SetAwsProfile()
{
#if DEBUG
Environment.SetEnvironmentVariable("AWS_Profile", "sdt-data-wrangler-Service-Role");
#endif
var services = ServiceCollectionFactory.Create();
_serviceProvider = services.BuildServiceProvider();
var sfOptions = _serviceProvider.GetService<IOptions<SnowflakeEnvironmentOptions>>();
var sfConnBuilderFactory = _serviceProvider.GetRequiredService<ISnowflakeConnectionStringBuilderFactory>();
var builder = sfConnBuilderFactory.CreateAsync($"stratareplication/snowflake/{_DatabaseGuid:N}/connectionstring", _DatabaseGuid).GetAwaiter().GetResult();
builder.Warehouse = sfOptions.Value.StandardsWarehouse;
_dbSnowflakeConnection = builder.CreateConnection();
}
}
}