Unit testing framework for Sitecore.
C# Other

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.