Questions tagged [fakedb]

FakeDb is an open source unit testing framework for Sitecore that enables creation and manipulation of Sitecore content in memory.

Filter by
Sorted by
Tagged with
3 votes
1 answer
106 views

Unit testing a Sitecore component controller throws exception in mocked service

I'm using xUnit, NSubstitute, FluentAssertions and Sitecore FakeDb. Here is the controller that needs a test, public class TransactionsController : Controller { private readonly ...
user avatar
0 votes
3 answers
157 views

Error while using Sitecore Fake DB with Sitecore 8.2

I am getting an error as: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The ...
user avatar
2 votes
1 answer
761 views

Sitecore.Exceptions.ConfigurationException:'Could not create instance of type:Sitecore.Data.Managers.ItemProvider.No matching constructor was found.'

I have implemented Xunit unit testing (ver 2.4.1) with Sitecore.FakeDb (ver 2.0.1) in Sitecore 9.3 version. After implementation when I run the test I am getting below exception. Sitecore.Exceptions....
user avatar
  • 51
2 votes
1 answer
1k views

FakeDB unit tests erroring

I'm trying to get some unit tests running in my Sitecore environment, where I'm using FakeDB as the testing framework. I've added the relevant NuGet packages in my Visual Studio project (which are ...
user avatar
  • 1,073
2 votes
1 answer
242 views

FakeDB runs into error when unit tests executed in parallel

I am facing a weird problem with Sitecore 9.2.0 and FakeDb 2.0.1. Some of the unit tests fails randomly with the following error. System.NullReferenceException Object reference not set to an instance ...
user avatar
  • 141
1 vote
1 answer
283 views

Unable to switch page DisplayMode in unit test

I am trying to test one of the properties which checks for the PageMode.IsExperienceEditor. Reduced implementation of my property is given below: public ContentResult DataSourceNotConfiguredResult { ...
user avatar
3 votes
1 answer
70 views

Using TDS project items in FakeDb.Serialization

I have a test project for a module where I'd like to use FakeDb. Because I have a TDS project where store items for master database, I'd like to use them for tests with FakeDb.Serialization. When I ...
user avatar
  • 343
-1 votes
1 answer
439 views

Sitecore FakeDB Set Template Standard values

I am working on unit tests. So I am using fake DB. I am trying to set template standard values. So I used below code. Item newItem = db.GetItem(contextId); var standardValues = newItem.Template....
user avatar
  • 11
2 votes
1 answer
517 views

Unable to get AutoFixture, FakeDb and NUnit3 combination to work

Has anyone been able to get the combination of AutoFixure, FakeDb and NUnit3 to work? I am unable to retrieve an item I have added to the database (using example from FakeDb AutoFixture wiki page); ...
user avatar
0 votes
1 answer
123 views

Sitecore FakeDB Deserialisation and Unicorn

Using Sitecore 9.0.1, Im looking at using Sitecore Fake DB for unit testing. Im interested in using the Deserialisation extension so that I can test using content that's been serialised to disk ...
user avatar
2 votes
1 answer
650 views

Fake a Media Item for Unit Testing

Is possible to autogenerate a Media "element" ? I am trying to do this mediaProvider.GetMedia(Arg.Is<Sitecore.Data.Items.MediaItem>(i => i.ID == mediaItemId)).Returns(Arg.Any<Media>()...
user avatar
  • 35
0 votes
1 answer
432 views

Faking a MediaRequest and Media Items

I am currently trying to mock a media request and the media item I am requesting using FakeDb but for some reason my request is returning an empty MediaPath rather than the MediaPath I am expecting. ...
user avatar
1 vote
1 answer
567 views

Setting up FakeSiteContext for urls

I am currently trying to create a unittest for a override I made, but unittesting it seems a bit more difficult than I expected.. public class Extension : Original { public fallback(...
user avatar
  • 35
6 votes
1 answer
2k views

NullReferenceException from Sitecore.Nexus on Sitecore 9.1

I am starting up my Sitecore 9.1 XP instance and I see the following error from Sitecore.Nexus: [NullReferenceException: Object reference not set to an instance of an object.] Sitecore.Nexus....
user avatar
0 votes
1 answer
848 views

Unit testing Sitecore ContentSearchManager

I have the following code that returns Items: public static IList<Item> GetAll(Language language) { var index = $"my_index_{Context.Database.Name.ToLowerInvariant()}"; using (var ...
user avatar
  • 285
1 vote
1 answer
1k views

Fake DB on Sitecore.data.Items.Item.add method

I'm creating a unit test for a code that has an Item.Add method used and trying to use Sitecore Fake DB for this and I'm getting an error that it's not being populated. A sample code below: public ...
user avatar
  • 379
1 vote
1 answer
1k views

Mocking the Authentication Provider

I'm trying to Unit test my login method, for that I used below provider var provider = Substitute.For<Sitecore.Security.Authentication.AuthenticationProvider>(); provider ...
user avatar
  • 443
2 votes
2 answers
580 views

URL encoding in HttpRequestArgs while unit testing

I'm putting together unit tests for item resolver running under httpRequest pipeline. One of the test is checking if the item is properly resolved using display name with asian characters (Japanese). ...
user avatar
  • 343
0 votes
1 answer
2k views

Sitecore.Context.Item is Overwritten by RenderingContext.Current.Rendering

I'm new to Sitecore FakeDb NUnit Testing. While testing the code, I found that Sitecore.Context.Item = null; RenderingContext.Current.Rendering.DataSource = fakeItem.ID.ToString(); Since the item ...
user avatar
  • 317
5 votes
1 answer
519 views

Alternatives to using custom pipelines for improved unit testability

What are common or effective approaches for making Pipelines in Sitecore unit testable? I recently updated some code to use custom pipelines and then found I could no longer unit test it :-( In the ...
user avatar
1 vote
1 answer
670 views

Sitecore Fake Db with GetSetting Sitecore method [duplicate]

I am trying to use sitecore Fake DB for unit testing. My custom config look like this <sitecore> <settings> <setting name="test1" value="value1" /> <setting name="test2" ...
user avatar
1 vote
2 answers
1k views

Error: Could not resolve type name: Sitecore.Data.DefaultDatabase, Sitecore.Kernel

I've recently imported a couple of the Test projects from a site running Sitecore 8.2 into a site running 7.2. When I run the tests, they all error with the message Could not resolve type name: ...
user avatar
  • 373
3 votes
2 answers
519 views

Mock MediaProvider on 8.2

I am using FakeDB trying to mock a media provider. I get this message when attempting the example shown in the wiki. Starting from Sitecore 8.2, the Sitecore.Resources.Media.MediaProvider class is ...
user avatar
  • 31
2 votes
2 answers
1k views

Adding DbItem under media library with FakeDb

When using FakeDb, and I set the full path of a DbItem to go under the media library, the path gets changed to the /sitecore/content/home/image-item. //Method starts here public void ...
user avatar
2 votes
3 answers
527 views

Problem retrieving FakeDb DbLinkField attributes

db.Add(new DbTemplate("t1", t1_TemplateId)); db.Add(new DbTemplate("T", T_TemplateId) { BaseIDs = new[] { t1_TemplateId} }); db.Add(new DbItem("root") { new DbItem("...
user avatar
  • 325