Skip to content
Unit testing framework for Sitecore.
C# Other
  1. C# 99.6%
  2. Other 0.4%
Branch: master
Clone or download
Pull request Compare This branch is 234 commits behind sshushliapin:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
src
.gitattributes
.gitignore
CHANGELOG.md
LICENSE
README.md
build.bat
build.config
build.msbuild
deploy.bat

README.md

Sitecore FakeDb

# #

This is the unit testing framework for Sitecore that enables creation and manipulation of Sitecore content in memory. It is designed to minimize efforts for the test content initialization keeping focus on the minimal test data rather than comprehensive content tree representation.

Here is a typical FakeDb unit test:

[Fact]
public void HowToCreateSimpleItem()
{
  using (var db = new Db
    {
      new DbItem("Home") { { "Title", "Welcome!" } }
    })
  {
    Sitecore.Data.Items.Item home = db.GetItem("/sitecore/content/home");
    Xunit.Assert.Equal("Welcome!", home["Title"]);
  }
}

Install with NuGet

You can install the framework via NuGet:

PM> Install-Package Sitecore.FakeDb

For information about configuring assembly references and applying the license file, see the Installation page.

Create items in memory

Explore the following list of articles to start creating items for your unit tests:

Or create your content using deserialized data.

Mock all the rest

With FakeDb you can configure behavior of the static managers substituting the corresponding providers with mocks. The following security providers can be mocked:

You can also configure behavior of other areas such as:

For more information about the FakeDb features follow the wiki pages.

You can’t perform that action at this time.