System.Configuration.Abstractions icon indicating copy to clipboard operation
System.Configuration.Abstractions copied to clipboard

Mocking out configuration section

Open viskin opened this issue 10 years ago • 2 comments

I use IConfigurationManager to mock configuration, but I found no easy way to mock values stored in configuration sections.

For example, I want to change session timeout during test.

I get session timeout from web.config in following way:

  SessionStateSection section =  (SessionStateSection)_configurationManager.GetSection("system.web/sessionState");
  sessionTimeout = TimeSpan.FromMinutes((int)section.Timeout.TotalMinutes);

where _configurationManager is instance of IConfigurationManager.

How can I set values for "system.web/sessionState" section using System.Configuration.Abstractions?

viskin avatar Sep 30 '15 10:09 viskin

Hey - at the moment custom configuration sections aren't supported. There's no reason they can't be however.

I'm on holiday from tomorrow until the 20th, but I'll take a look at this when I get back and see what I can work in.

  • D

davidwhitney avatar Oct 01 '15 15:10 davidwhitney

My congratulations! CU

viskin avatar Oct 01 '15 15:10 viskin