davidwhitney / System.Configuration.Abstractions

Injectable, mockable, extensible, configuration for .NET
MIT License
42 stars 7 forks source link

Mocking out configuration section #9

Open viskin opened 8 years ago

viskin commented 8 years ago

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?

davidwhitney commented 8 years ago

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.

viskin commented 8 years ago

My congratulations! CU