Initial commit: SWP.Core enterprise framework with multi-tenant architecture, configuration management, security, telemetry and comprehensive test suite
This commit is contained in:
commit
5275a75502
87 changed files with 6140 additions and 0 deletions
75
Tests/ConfigurationTests/KeyValueJsonHandlingTests.cs
Normal file
75
Tests/ConfigurationTests/KeyValueJsonHandlingTests.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using SWP.Core.Configurations.Common;
|
||||
|
||||
namespace SWP.Core.X.TDD.ConfigurationTests;
|
||||
|
||||
[TestClass]
|
||||
public class ConfigurationTests : TestFixture
|
||||
{
|
||||
[TestInitialize]
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void ConfigurationSettingsTest()
|
||||
{
|
||||
var pairs = new List<KeyValuePair<string, JToken>>
|
||||
{
|
||||
new("Debug", true),
|
||||
// Database konfiguration
|
||||
new("Database:ConnectionString", "Server=db.example.com;Port=5432"),
|
||||
new("Database:Timeout", 30),
|
||||
new("Database:UseSSL", true),
|
||||
|
||||
// Logging konfiguration med JObject
|
||||
new("Logging:FileOptions", JObject.Parse(@"{
|
||||
'Path': '/var/logs/app.log',
|
||||
'MaxSizeMB': 100,
|
||||
'RetentionDays': 7
|
||||
}")),
|
||||
|
||||
// Feature flags med kompleks konfiguration
|
||||
new("Features:Experimental", JObject.Parse(@"{
|
||||
'Enabled': true,
|
||||
'RolloutPercentage': 25,
|
||||
'AllowedUserGroups': ['beta']
|
||||
}")),
|
||||
|
||||
// API endpoints med array
|
||||
new("API:Endpoints", "/api/users"),
|
||||
new("API:Endpoints", "/api/products")
|
||||
};
|
||||
|
||||
var result = KeyValueToJson.Convert(pairs);
|
||||
|
||||
var expected = JObject.Parse(@"{
|
||||
'Debug' : true,
|
||||
'Database': {
|
||||
'ConnectionString': 'Server=db.example.com;Port=5432',
|
||||
'Timeout': 30,
|
||||
'UseSSL': true
|
||||
},
|
||||
'Logging': {
|
||||
'FileOptions': {
|
||||
'Path': '/var/logs/app.log',
|
||||
'MaxSizeMB': 100,
|
||||
'RetentionDays': 7
|
||||
}
|
||||
},
|
||||
'Features': {
|
||||
'Experimental': {
|
||||
'Enabled': true,
|
||||
'RolloutPercentage': 25,
|
||||
'AllowedUserGroups': ['beta']
|
||||
}
|
||||
},
|
||||
'API': {
|
||||
'Endpoints': ['/api/users', '/api/products']
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.IsTrue(JToken.DeepEquals(expected, result));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue