-
Notifications
You must be signed in to change notification settings - Fork 36
Configuration
sergeyshushlyapin edited this page May 25, 2015
·
14 revisions
Sitecore.FakeDb automatically includes configuration files located in the <test_project>\App_Config\Include
folder. You can read more about the include files in the following post:
ALL ABOUT WEB.CONFIG INCLUDE FILES WITH THE SITECORE ASP.NET CMS | JOHN WEST | SITECORE BLOG.
- In a unit test project, create a new
App_Config\Include\MyUnitTests.config
file which contains the required configuration, for instance, theMyApp.Enabled
setting:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="MyApp.Enabled" value="true" />
</settings>
</sitecore>
</configuration>
- In a unit test, read the setting using the regular
Sitecore.Configuration.Settings
class:
[Fact]
public void ShouldReadMyAppEnabledSetting()
{
var enabled =
Sitecore.Configuration.Settings.GetBoolSetting("MyApp.Enabled", false);
Assert.True(enabled);
}
To run tests that require include files with NCrunch, in the <test_project>.ncrunchproject
file, configure the following settings:
<CopyReferencedAssembliesToWorkspace>true</CopyReferencedAssembliesToWorkspace>
<AdditionalFilesToInclude>license.xml;App_Config\**.*</AdditionalFilesToInclude>
Read more about the configuration on the NCrunch documentation website: