wip on tests
This commit is contained in:
parent
440087c43b
commit
75e0406251
4 changed files with 234 additions and 165 deletions
|
|
@ -14,6 +14,7 @@ namespace Tests.ConfigurationTests
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class JsonConfigurationProviderTests : TestFixture
|
public class JsonConfigurationProviderTests : TestFixture
|
||||||
{
|
{
|
||||||
|
public JsonConfigurationProviderTests() : base("ConfigurationTests") { }
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetSection_ShouldReturnCorrectFeatureSection()
|
public void GetSection_ShouldReturnCorrectFeatureSection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
60
Tests/ConfigurationTests/appconfiguration.dev.json
Normal file
60
Tests/ConfigurationTests/appconfiguration.dev.json
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
|
||||||
|
},
|
||||||
|
"ApplicationInsights": {
|
||||||
|
"ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/"
|
||||||
|
},
|
||||||
|
"Authentication": "SHA256",
|
||||||
|
"Feature": {
|
||||||
|
"Enabled": true,
|
||||||
|
"RolloutPercentage": 25,
|
||||||
|
"AllowedUserGroups": [ "beta" ]
|
||||||
|
},
|
||||||
|
"AnotherSetting": {
|
||||||
|
|
||||||
|
"Thresholds": {
|
||||||
|
"High": "123",
|
||||||
|
"Low": "-1"
|
||||||
|
},
|
||||||
|
"Temperature": {
|
||||||
|
|
||||||
|
"Indoor": {
|
||||||
|
"Max": { "Limit": 22 },
|
||||||
|
"Min": { "Limit": 18 }
|
||||||
|
},
|
||||||
|
"Outdoor": {
|
||||||
|
"Max": { "Limit": 12 },
|
||||||
|
"Min": { "Limit": 9 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Serilog": {
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"System": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "Seq",
|
||||||
|
"Args": {
|
||||||
|
"serverUrl": "http://localhost:5341",
|
||||||
|
"apiKey": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [
|
||||||
|
"WithMachineName",
|
||||||
|
"WithThreadId",
|
||||||
|
"WithProcessId",
|
||||||
|
"WithEnvironmentName"
|
||||||
|
],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "PlanTempus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,13 +14,15 @@ namespace Tests
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public abstract partial class TestFixture
|
public abstract partial class TestFixture
|
||||||
{
|
{
|
||||||
|
private readonly string _configurationFilePath;
|
||||||
|
|
||||||
protected IContainer Container { get; private set; }
|
protected IContainer Container { get; private set; }
|
||||||
protected ContainerBuilder ContainerBuilder { get; private set; }
|
protected ContainerBuilder ContainerBuilder { get; private set; }
|
||||||
|
|
||||||
public virtual IConfigurationRoot Configuration()
|
public virtual IConfigurationRoot Configuration()
|
||||||
{
|
{
|
||||||
var configuration = new ConfigurationBuilder()
|
var configuration = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_configurationFilePath}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
|
|
@ -31,7 +33,10 @@ namespace Tests
|
||||||
CreateContainerBuilder();
|
CreateContainerBuilder();
|
||||||
Container = ContainerBuilder.Build();
|
Container = ContainerBuilder.Build();
|
||||||
}
|
}
|
||||||
|
public TestFixture(string configurationFilePath) : this()
|
||||||
|
{
|
||||||
|
_configurationFilePath = configurationFilePath;
|
||||||
|
}
|
||||||
protected virtual void CreateContainerBuilder()
|
protected virtual void CreateContainerBuilder()
|
||||||
{
|
{
|
||||||
IConfigurationRoot configuration = Configuration();
|
IConfigurationRoot configuration = Configuration();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
<None Update="appconfiguration.dev.json">
|
<None Update="appconfiguration.dev.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="ConfigurationTests\appconfiguration.dev.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue