wip
This commit is contained in:
parent
0f1a345216
commit
e73f428c49
6 changed files with 96 additions and 144 deletions
|
|
@ -9,7 +9,11 @@ namespace Tests.ConfigurationTests
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class JsonConfigurationProviderTests : TestFixture
|
public class JsonConfigurationProviderTests : TestFixture
|
||||||
{
|
{
|
||||||
public JsonConfigurationProviderTests() : base("ConfigurationTests") { }
|
const string _testFolder = "ConfigurationTests/";
|
||||||
|
|
||||||
|
public JsonConfigurationProviderTests() : base(_testFolder) { }
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetSection_ShouldReturnCorrectFeatureSection()
|
public void GetSection_ShouldReturnCorrectFeatureSection()
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +25,7 @@ namespace Tests.ConfigurationTests
|
||||||
}") as JToken;
|
}") as JToken;
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -44,7 +48,7 @@ namespace Tests.ConfigurationTests
|
||||||
};
|
};
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -64,7 +68,7 @@ namespace Tests.ConfigurationTests
|
||||||
var expectedFeature = "123";
|
var expectedFeature = "123";
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -83,7 +87,7 @@ namespace Tests.ConfigurationTests
|
||||||
var expected = "SHA256";
|
var expected = "SHA256";
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -99,7 +103,7 @@ namespace Tests.ConfigurationTests
|
||||||
var expectedFeature = 22;
|
var expectedFeature = 22;
|
||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -115,7 +119,7 @@ namespace Tests.ConfigurationTests
|
||||||
var expectedFeature = true;
|
var expectedFeature = true;
|
||||||
|
|
||||||
var configRoot = new ConfigurationBuilder()
|
var configRoot = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appconfiguration.dev.json")
|
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||||
.AddSmartConfig()
|
.AddSmartConfig()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,15 @@ namespace Tests
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TestFixture()
|
protected TestFixture() : this(null) { }
|
||||||
|
public TestFixture(string configurationFilePath)
|
||||||
{
|
{
|
||||||
|
if (configurationFilePath is not null)
|
||||||
|
_configurationFilePath = configurationFilePath?.TrimEnd('/') + "/";
|
||||||
|
|
||||||
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();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="xappconfiguration.dev.json">
|
<None Update="appconfiguration.dev.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="ConfigurationTests\appconfiguration.dev.json">
|
<None Update="ConfigurationTests\appconfiguration.dev.json">
|
||||||
|
|
|
||||||
8
Tests/appconfiguration.dev.json
Normal file
8
Tests/appconfiguration.dev.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"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/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue