This page last changed on Sep 26, 2006 by hmobius.

Each test assembly can have a separate config file. MbUnit will setup the AppDomain to use the separate config file. The naming convention is as usual: Assembly name + '.config'

MyTestAssembly.dll -> MyTestAssembly.dll.config

Example:

The following test illustrate the use of config files in assemblies.

Files in project:

app.config
test.cs

app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="DummyValue" value="HelloWorld" />
    </appSettings>
</configuration>
test.cs
Unable to find source-code formatter for language: cs. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
using System;
using System.Configuration;
using MbUnit.Framework;

namespace Test.Example
{
   [TestFixture]
   public class ConfigTest
   {
        [Test]
        public void GetValueFromAppSettings()
        {            string helloWorld = ConfigurationManager.AppSettings["DummyValue"];
            Assert.AreEqual("HelloWorld", helloWorld);
        }
   }
}
Note

.NET 1.x users should replace ConfigurationManager.AppSettings["DummyValue"] with ConfigurationSettings.AppSettings["DummyValue"] to get this example working

Output
------ Test started: Assembly: MbUnitTestSamples.dll ------

 Info: Test Execution
 Info: Exploring Test.Example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 Info: MbUnit 1.0.2445.37068 Addin
 Info: Found 1 tests
 Info: [success] ConfigTest.GetValueFromAppSettings
 Info: [reports] generating HTML report
 TestResults: ....\Test.Example.Tests.html

 1 succeeded, 0 failed, 0 skipped, took 4.07 seconds.
Document generated by Confluence on Jun 11, 2007 11:56