Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sshushliapin/Sitecore.FakeDb
Unit testing framework for Sitecore.
https://github.com/sshushliapin/Sitecore.FakeDb
Last synced: 3 months ago
JSON representation
Unit testing framework for Sitecore.
- Host: GitHub
- URL: https://github.com/sshushliapin/Sitecore.FakeDb
- Owner: sshushliapin
- License: mit
- Created: 2014-01-22T15:56:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T01:05:37.000Z (almost 2 years ago)
- Last Synced: 2024-04-04T20:06:48.404Z (7 months ago)
- Language: C#
- Homepage:
- Size: 8.89 MB
- Stars: 117
- Watchers: 20
- Forks: 35
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Sitecore - Sitecore FakeDb - A unit testing framework for Sitecore that enables the 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. (Testing)
README
Sitecore FakeDb
===============![#](https://img.shields.io/nuget/vpre/Sitecore.FakeDb.svg)
![Build Status](https://dev.azure.com/sshushliapin/Sitecore-FakeDb/_apis/build/status/sshushliapin.Sitecore.FakeDb?branchName=master)
![tests](https://img.shields.io/azure-devops/tests/sshushliapin/Sitecore-FakeDb/1)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:
```csharp
[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](https://www.nuget.org/packages/Sitecore.FakeDb/):
``` powershell
PM> Install-Package Sitecore.FakeDb
```For information about configuring assembly references and applying the license file, see the [Installation](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Installation) page.
## Create items in memory
Explore the following list of articles to start creating items for your unit tests:
- [Creating a simple item](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Creating-a-Simple-Item)
- [Creating a hierarchy of items](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Creating-a-Hierarchy-of-Items)
- [Creating an item based on a template](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Creating-an-Item-Based-on-a-Template)Or create your content using [deserialized data](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/FakeDb-Serialization).
## 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:
- [Authentication](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-Authentication-Provider)
- [Authorization](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-Authorization-Provider)
- [Role](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-Role-Provider)
- [Roles-In-Roles](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-RolesInRoles-Provider)
- [Membership](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-Membership-Provider)You can also configure behavior of other areas such as:
- [Link Database](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Links)
- [Media Provider](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Media)
- [IDTable](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Mocking-the-IDTable)
- [Pipelines](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Pipelines)
- [Settings](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki/Settings)For more information about the FakeDb features follow the [wiki](https://github.com/sergeyshushlyapin/Sitecore.FakeDb/wiki) pages.