Auto stash before merge of "main" and "origin/main"
This commit is contained in:
parent
21d7128e74
commit
521190475d
41 changed files with 991 additions and 1150 deletions
102
Tests/ConfigurationTests/SmartConfigProviderTests.cs
Normal file
102
Tests/ConfigurationTests/SmartConfigProviderTests.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using Core.Configurations.SmartConfig;
|
||||
using Core.Configurations;
|
||||
using FluentAssertions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Core.Configurations.JsonConfigProvider;
|
||||
using Autofac;
|
||||
using System.Data;
|
||||
using Insight.Database;
|
||||
using Npgsql;
|
||||
|
||||
namespace Tests.ConfigurationTests
|
||||
{
|
||||
[TestClass]
|
||||
public class SmartConfigProviderTests : TestFixture
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = true;
|
||||
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.AddSmartConfig()
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = config.Get<bool>("Database:UseSSL");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueWhenSelectingIntoValueRowInConfigTable()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = 100;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.AddSmartConfig()
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("Logging:FileOptions").Get<int>("MaxSizeMB");
|
||||
var withoutSectionThisAlsoWorks = builder.Get<int>("Logging:FileOptions:MaxSizeMB");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
actualFeature.Should().Be(withoutSectionThisAlsoWorks);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPostgresSearchPath()
|
||||
{
|
||||
//ALTER USER sathumper SET search_path TO ptmain, public;
|
||||
|
||||
var conn = Container.Resolve<IDbConnection>();
|
||||
|
||||
var result = conn.QuerySql("SHOW search_path;");
|
||||
using (var connw = new NpgsqlConnection(conn.ConnectionString + ";Password=3911"))
|
||||
{
|
||||
connw.Open();
|
||||
using (var cmd = new NpgsqlCommand("SHOW search_path; SELECT current_user;", connw))
|
||||
{
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
reader.Read();
|
||||
var r1 = $"Search path: {reader.GetString(0)}";
|
||||
reader.NextResult();
|
||||
reader.Read();
|
||||
var r2 = $"Current schema: {reader.GetString(0)}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
[TestMethod]
|
||||
public void TryGetActiveConfigurations()
|
||||
{
|
||||
|
||||
const string sql = @"
|
||||
SELECT id, ""key"", value, label, content_type,
|
||||
valid_from, expires_at, created_at, modified_at, etag
|
||||
FROM app_configuration
|
||||
WHERE CURRENT_TIMESTAMP BETWEEN valid_from AND expires_at
|
||||
OR (valid_from IS NULL AND expires_at IS NULL)";
|
||||
|
||||
var conn = Container.Resolve<IDbConnection>();
|
||||
|
||||
var result = conn.QuerySql(sql);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue