Template
chore: deploy initial code base
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
using Moq;
|
||||
using Strata.CoreLib.Claims;
|
||||
using Strata.DecisionSupport.Biz.Services;
|
||||
using Strata.DecisionSupport.Biz.Snowflake;
|
||||
using Strata.Schema.Client;
|
||||
using Strata.Schema.Client.Dtos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using VerifyTests;
|
||||
|
||||
namespace Strata.DecisionSupport.Biz.Test.Unit.Services
|
||||
{
|
||||
[TestFixture, Category("Unit"), Category("DSS")]
|
||||
public class EncounterQueryServiceTests
|
||||
{
|
||||
public VerifySettings verifySettings;
|
||||
|
||||
public EncounterQueryService service { get; set; }
|
||||
public ISnowflakeDatabaseContext snowflakeDbContext { get; set; }
|
||||
public ISchemaServiceClient schemaServiceClient { get; set; }
|
||||
public IClaimsPrincipalAccessor claimsPrincipalAccessor { get; set; }
|
||||
|
||||
internal static Guid configurationGuid { get; set; } = Guid.NewGuid();
|
||||
internal static Guid serviceLineDimensionGuid { get; set; } = Guid.NewGuid();
|
||||
internal static Guid sg2DimensionGuid { get; set; } = Guid.NewGuid();
|
||||
internal static Guid defaultKeyGuid { get; set; } = Guid.NewGuid();
|
||||
internal static Guid defaultLookupKeyGuid { get; set; } = Guid.NewGuid();
|
||||
|
||||
public const string UserGuid = "eb7e4993-c65a-493a-9614-986a55dd0744";
|
||||
public const string DbGuid = "54409f55-5ddf-4748-8222-9ccfb04fb4f5";
|
||||
public const string ClientDbGuid = "1742934B-C508-402B-B8B5-D18C506474CB";
|
||||
public const string Username = "a";
|
||||
public const string Key = UserGuid + Username;
|
||||
public const string DbVersion = "202133";
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
verifySettings = TestExtensions.TestSettings();
|
||||
snowflakeDbContext = Mock.Of<ISnowflakeDatabaseContext>();
|
||||
|
||||
var scoreDimension = new ScoreDimensionDto
|
||||
{
|
||||
DimensionGuid = serviceLineDimensionGuid,
|
||||
DefaultKeyGuid = defaultKeyGuid,
|
||||
DefaultLookupKeyGuid = defaultLookupKeyGuid,
|
||||
FriendlyName = "ServiceLine",
|
||||
SourceTableSchema = "fw",
|
||||
SourceTableName = "serviceLine",
|
||||
Attributes = new List<ScoreAttributeDto>
|
||||
{
|
||||
new ScoreAttributeDto
|
||||
{
|
||||
AttributeGuid = defaultKeyGuid,
|
||||
SqlColumnName = "Name"
|
||||
},
|
||||
new ScoreAttributeDto
|
||||
{
|
||||
AttributeGuid = defaultLookupKeyGuid,
|
||||
SqlColumnName = "Name"
|
||||
}
|
||||
}
|
||||
};
|
||||
var sg2Dimension = new ScoreDimensionDto
|
||||
{
|
||||
DimensionGuid = serviceLineDimensionGuid,
|
||||
DefaultKeyGuid = defaultKeyGuid,
|
||||
DefaultLookupKeyGuid = defaultLookupKeyGuid,
|
||||
FriendlyName = "Sg2 Service Line Crosswalk",
|
||||
SourceTableSchema = "fw",
|
||||
SourceTableName = "serviceLine",
|
||||
Attributes = new List<ScoreAttributeDto>
|
||||
{
|
||||
new ScoreAttributeDto
|
||||
{
|
||||
AttributeGuid = defaultKeyGuid,
|
||||
SqlColumnName = "Name"
|
||||
},
|
||||
new ScoreAttributeDto
|
||||
{
|
||||
AttributeGuid = defaultLookupKeyGuid,
|
||||
SqlColumnName = "Name"
|
||||
}
|
||||
}
|
||||
};
|
||||
schemaServiceClient = Mock.Of<ISchemaServiceClient>();
|
||||
Mock.Get(schemaServiceClient)
|
||||
.Setup(x => x.GetGMDimensionAsync(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
|
||||
.Returns<Guid, CancellationToken>((dimensionGuid, token) =>
|
||||
dimensionGuid.Equals(serviceLineDimensionGuid)
|
||||
? Task.FromResult(scoreDimension)
|
||||
: Task.FromResult(sg2Dimension));
|
||||
|
||||
claimsPrincipalAccessor = Mock.Of<IClaimsPrincipalAccessor>();
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim(ClaimTypes.Name, "Name"),
|
||||
new Claim(StrataClaims.UserGuid, UserGuid),
|
||||
new Claim(StrataClaims.Username, Username),
|
||||
new Claim("given_name", "Firstname"),
|
||||
new Claim("family_name", "Lastname"),
|
||||
new Claim(StrataClaims.FirstName, "Firstname"),
|
||||
new Claim(StrataClaims.LastName, "Lastname"),
|
||||
new Claim(StrataClaims.DatabaseVersion, DbVersion),
|
||||
new Claim(StrataClaims.DatabaseGuid, ClientDbGuid),
|
||||
new Claim(StrataClaims.IsSdtEmployee,true.ToString())
|
||||
};
|
||||
var claimIdentity = new ClaimsIdentity(claims, "mock");
|
||||
var claimsPrincipal = new ClaimsPrincipal(new[] { claimIdentity });
|
||||
|
||||
Mock.Get(claimsPrincipalAccessor)
|
||||
.Setup(x => x.GetCurrentClaimsPrincipal())
|
||||
.Returns(claimsPrincipal);
|
||||
|
||||
service = new EncounterQueryService(snowflakeDbContext, schemaServiceClient);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user