We’re rewarding the question askers & reputations are being recalculated! Read more.

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
1
vote
1answer
45 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 { ...
2
votes
1answer
38 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 ...
-1
votes
1answer
107 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....
2
votes
1answer
158 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); ...
0
votes
1answer
77 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 ...
2
votes
1answer
219 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>()...
0
votes
1answer
155 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. ...
1
vote
1answer
132 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(...
6
votes
1answer
684 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....
0
votes
1answer
235 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 ...
1
vote
1answer
379 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 ...
1
vote
1answer
495 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 ...
2
votes
2answers
295 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). ...
0
votes
1answer
896 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 ...
4
votes
1answer
288 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 ...
1
vote
1answer
318 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" ...
1
vote
2answers
871 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: ...
2
votes
2answers
416 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 ...
2
votes
2answers
758 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 ...
2
votes
3answers
222 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("...