Finalizes ConfigurationBuilder with indexer
This commit is contained in:
parent
1f675498a2
commit
6839cd82e2
5 changed files with 43 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ using Autofac;
|
|||
using System.Data;
|
||||
using Insight.Database;
|
||||
using Npgsql;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Tests.ConfigurationTests
|
||||
{
|
||||
|
|
@ -52,7 +53,9 @@ namespace Tests.ConfigurationTests
|
|||
|
||||
// Act
|
||||
var actualFeature = builder.GetSection("Feature").ToObject<Feature>();
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
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);
|
||||
|
|
@ -74,6 +77,25 @@ namespace Tests.ConfigurationTests
|
|||
// Assert
|
||||
actualFeature.Should().BeEquivalentTo(expectedFeature);
|
||||
}
|
||||
/// <summary>
|
||||
/// Testing a stupid indexer for compability with Microsoft ConfigurationBuilder
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void Indexer_ShouldReturnValueAsString()
|
||||
{
|
||||
// Arrange
|
||||
var expected = "SHA256";
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
// Act
|
||||
var actual = builder["Authentication"];
|
||||
|
||||
// Assert
|
||||
actual.Should().BeEquivalentTo(expected);
|
||||
}
|
||||
[TestMethod]
|
||||
public void Get_ShouldReturnCorrectValueAsInt()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue