Search code examples
c#mbunitgallio

Using app.config in MBunit test


The way I have my unit test set up is that a user can run the executable and select a dataset to use. This information is stored in app.config, however when I try to access app.config when running the unit test with Gallio Icarus it doesn't work.

Edit: I got the field to bind to an Application property however when I call Properties.Settings.Default.Save(); it doesn't seem to do anything. The app.exe.config does not change and the changes does not persist.


Solution

  • app.config is the file that corresponds to the MyProgramme.exe.config file that the programme reads on start up. This can be accessed via the Configuration object in the System.Configuration namespace and assembly.

    Properties.Settings.Default corresponds to the file user.config that your programme will generate when you call Properties.Settings.Default.Save()

    So including the app.config file in the tests won't affect Properties.Settings.Default.

    For more information see Using Settings