I’m trying to Bind
a Dictionary<string,string>
to a configuration section like this:
[TestFixture]
public class When_binding_a_configuration_section
{
[Test]
public void should_contain_section()
{
var config = new ConfigurationBuilder()
.AddInMemoryCollection()
.Build();
var dict = new Dictionary<string, string>()
{
{ "Key", "Value" }
};
config.Bind("Section", dict);
var section = config.GetSection("Section");
section.GetSection("Section").ShouldNotBeNull(); // true
section["Key"].ShouldBe("Value"); // false
}
}
The first assertion succeeds while the section one fails.
What am I doing wrong here?