Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 415 Bytes

iconfiguration-in-unit-test.md

File metadata and controls

17 lines (12 loc) · 415 Bytes

IConfiguration in Unit Test

You can use an actual Configuration instance with in-memory data.

var inMemorySettings = new Dictionary<string, string> {
    {"TopLevelKey", "TopLevelValue"},
    {"SectionName:SomeKey", "SectionValue"},
    //...populate as needed for the test
};

IConfiguration configuration = new ConfigurationBuilder()
    .AddInMemoryCollection(inMemorySettings)
    .Build();