-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #5 Ignore properties with the CompilerGenerated attribute
- Loading branch information
1 parent
41fae51
commit 9719ba4
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/Extensionsions.Configuration.Object.UnitTests/RecordObjectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Configuration; | ||
using Xunit; | ||
|
||
namespace Extensions.Configuration.Object.UnitTests | ||
{ | ||
public class RecordObjectTest | ||
{ | ||
internal record MyConfiguration | ||
{ | ||
public SubRecordConfiguration SubRecord; | ||
public string MyKey; | ||
} | ||
|
||
internal record SubRecordConfiguration | ||
{ | ||
public string Title; | ||
public string Name; | ||
public int Age; | ||
} | ||
|
||
[Fact] | ||
public void AddObject_WithRecordObject_ShouldLoadFieldsIntoConfiguration() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.AddObject(new MyConfiguration | ||
{ | ||
SubRecord = new SubRecordConfiguration | ||
{ | ||
Title = "Editor", | ||
Name = "Joe Smith", | ||
Age = 33 | ||
}, | ||
MyKey = "My appsettings.json Value", | ||
}) | ||
.Build(); | ||
|
||
configuration["SubRecord:Title"].Should().Be("Editor"); | ||
configuration["SubRecord:Name"].Should().Be("Joe Smith"); | ||
configuration["SubRecord:Age"].Should().Be("33"); | ||
configuration["MyKey"].Should().Be("My appsettings.json Value"); | ||
} | ||
} | ||
} |