This commit is contained in:
Janus C. H. Knudsen 2025-03-07 00:17:08 +01:00
parent 0010a32248
commit ddb6abc14e
14 changed files with 754 additions and 718 deletions

View file

@ -1,18 +1,16 @@
using PlanTempus.Database.ConfigurationManagementSystem;
using Insight.Database;
using System.Data;
using Newtonsoft.Json;
using System.Data;
using Autofac;
using Shouldly;
using Insight.Database;
using Newtonsoft.Json;
using PlanTempus.Core.Sql.ConnectionFactory;
using Shouldly;
namespace PlanTempus.Tests.ConfigurationSystem;
namespace PlanTempus.X.TDD.ConfigurationSystem;
[TestClass]
public class SetupConfigurationTests : TestFixture
{
private IDbConnection _connection;
private SetupConfiguration _setupConfiguration;
[TestInitialize]
public void Setup()
@ -52,15 +50,15 @@ public class SetupConfigurationTests : TestFixture
SELECT key, value, label, action_type
FROM app_configuration_history
WHERE id = @id AND action_type = 'I'",
new { id = (int)result.id })
new { id = (int)result.id })
.Single();
// Assert
var expected = JsonConvert.SerializeObject(new
{
key = configData.key,
value = configData.value,
label = configData.label,
configData.key,
configData.value,
configData.label,
action_type = "I"
});
var actual = JsonConvert.SerializeObject(history) as string;
@ -83,7 +81,7 @@ public class SetupConfigurationTests : TestFixture
RETURNING modified_at", configData)
.Single();
System.Threading.Thread.Sleep(1000);
Thread.Sleep(1000);
// Act
var updated = _connection.QuerySql<dynamic>(@"
@ -91,7 +89,7 @@ public class SetupConfigurationTests : TestFixture
SET value = @value
WHERE key = @key
RETURNING modified_at",
new { key = configData.key, value = "updated value" })
new { configData.key, value = "updated value" })
.Single();
// Assert
@ -124,13 +122,13 @@ public class SetupConfigurationTests : TestFixture
SELECT key, value, action_type
FROM app_configuration_history
WHERE id = @id AND action_type = 'D'",
new { id = (int)original.id })
new { id = (int)original.id })
.Single();
var expected = JsonConvert.SerializeObject(new
{
key = configData.key,
value = configData.value,
configData.key,
configData.value,
action_type = "D"
});
var actual = JsonConvert.SerializeObject(history) as string;
@ -177,10 +175,10 @@ public class SetupConfigurationTests : TestFixture
// Assert
var expected = JsonConvert.SerializeObject(new
{
key = configData.key,
value = configData.value,
label = configData.label,
content_type = configData.content_type,
configData.key,
configData.value,
configData.label,
configData.content_type,
valid_from = ((DateTimeOffset)configData.valid_from).ToUnixTimeSeconds(),
expires_at = ((DateTimeOffset)configData.expires_at).ToUnixTimeSeconds()
});