Adds LightBDD
This commit is contained in:
parent
099f6467d2
commit
104187fcac
16 changed files with 344 additions and 158 deletions
|
|
@ -1,5 +1,5 @@
|
|||
using FluentAssertions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Shouldly;
|
||||
using PlanTempus.Tests;
|
||||
using PlanTempus.Core.Configurations;
|
||||
using PlanTempus.Core.Configurations.JsonConfigProvider;
|
||||
|
|
@ -33,8 +33,8 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var section = builder.GetSection("Feature");
|
||||
|
||||
// Assert
|
||||
section.Should().NotBeNull();
|
||||
section.Value.Should().BeEquivalentTo(expectedJObject);
|
||||
section.ShouldNotBeNull();
|
||||
section.Value.ShouldBeEquivalentTo(expectedJObject);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -58,8 +58,8 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var actualFeatureObsoleted = builder.GetSection("Feature").Get<Feature>();
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
actualFeatureObsoleted.Should().BeEquivalentTo(expectedFeature);
|
||||
actualFeature.ShouldBeEquivalentTo(expectedFeature);
|
||||
actualFeatureObsoleted.ShouldBeEquivalentTo(expectedFeature);
|
||||
|
||||
}
|
||||
[TestMethod]
|
||||
|
|
@ -76,7 +76,7 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var actualFeature = builder.GetSection("AnotherSetting").Get<string>("Thresholds:High");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
actualFeature.ShouldBeEquivalentTo(expectedFeature);
|
||||
}
|
||||
/// <summary>
|
||||
/// Testing a stupid indexer for compability with Microsoft ConfigurationBuilder
|
||||
|
|
@ -95,7 +95,7 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var actual = builder["Authentication"];
|
||||
|
||||
// Assert
|
||||
actual.Should().BeEquivalentTo(expected);
|
||||
actual.ShouldBeEquivalentTo(expected);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsInt()
|
||||
|
|
@ -111,7 +111,7 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var actualFeature = builder.GetSection("AnotherSetting:Temperature").Get<int>("Indoor:Max:Limit");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
actualFeature.ShouldBe(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
|
|
@ -128,7 +128,7 @@ namespace PlanTempus.Tests.ConfigurationTests
|
|||
var actualFeature = configRoot.Get<bool>("Database:UseSSL");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
actualFeature.ShouldBe(expectedFeature);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using FluentAssertions;
|
||||
using Autofac;
|
||||
using Autofac;
|
||||
using Shouldly;
|
||||
using System.Data;
|
||||
using Insight.Database;
|
||||
using Npgsql;
|
||||
|
|
@ -10,78 +10,78 @@ using PlanTempus.Core.Configurations.SmartConfigProvider;
|
|||
|
||||
namespace PlanTempus.Tests.ConfigurationTests
|
||||
{
|
||||
[TestClass]
|
||||
public class SmartConfigProviderTests : TestFixture
|
||||
{
|
||||
[TestClass]
|
||||
public class SmartConfigProviderTests : TestFixture
|
||||
{
|
||||
const string _testFolder = "ConfigurationTests/";
|
||||
|
||||
[TestMethod]
|
||||
public void TrySmartConfigWithOptionsForPostgres()
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.AddSmartConfig(options => options.UsePostgres("DefaultConnection"))
|
||||
.Build();
|
||||
[TestMethod]
|
||||
public void TrySmartConfigWithOptionsForPostgres()
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.AddSmartConfig(options => options.UsePostgres("DefaultConnection"))
|
||||
.Build();
|
||||
|
||||
var actualFeature = config.Get<bool>("Database:UseSSL");
|
||||
var actualFeature = config.Get<bool>("Database:UseSSL");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = true;
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsBool()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = true;
|
||||
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.AddSmartConfig()
|
||||
.Build();
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.AddSmartConfig(options => options.UsePostgres("DefaultConnection"))
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = config.Get<bool>("Database:UseSSL");
|
||||
// Act
|
||||
var actualFeature = config.Get<bool>("Database:UseSSL");
|
||||
|
||||
// Assert
|
||||
actualFeature.Should().Be(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueWhenSelectingIntoValueRowInConfigTable()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = 100;
|
||||
// Assert
|
||||
actualFeature.ShouldBe(expectedFeature);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueWhenSelectingIntoValueRowInConfigTable()
|
||||
{
|
||||
// Arrange
|
||||
var expectedFeature = 100;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.AddSmartConfig()
|
||||
.Build();
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile($"{_testFolder}appconfiguration.dev.json")
|
||||
.AddSmartConfig(options => options.UsePostgres("DefaultConnection"))
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("Logging:FileOptions").Get<int>("MaxSizeMB");
|
||||
var withoutSectionThisAlsoWorks = builder.Get<int>("Logging:FileOptions:MaxSizeMB");
|
||||
// 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);
|
||||
// Assert
|
||||
actualFeature.ShouldBe(expectedFeature);
|
||||
actualFeature.ShouldBe(withoutSectionThisAlsoWorks);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TryGetActiveConfigurations()
|
||||
{
|
||||
[TestMethod]
|
||||
public void TryGetActiveConfigurations()
|
||||
{
|
||||
var connFactory = Container.Resolve<Database.Core.ConnectionFactory.IDbConnectionFactory>();
|
||||
|
||||
const string sql = @"
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using (var conn = connFactory.Create())
|
||||
{
|
||||
var result = conn.QuerySql(sql);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptmain;User Id=sathumper;Password=3911;"
|
||||
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=sandbox;User Id=sathumper;Password=3911;"
|
||||
},
|
||||
"ApplicationInsights": {
|
||||
"ConnectionString": "InstrumentationKey=07d2a2b9-5e8e-4924-836e-264f8438f6c5;IngestionEndpoint=https://northeurope-2.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/;ApplicationId=56748c39-2fa3-4880-a1e2-24068e791548",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue