Skip to content

Mocking out configuration section #9

@viskin

Description

@viskin

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions