Questions tagged [fakedb]
FakeDb is an open source unit testing framework for Sitecore that enables creation and manipulation of Sitecore content in memory.
27 questions
1
vote
2
answers
612
views
Exception while using Sitecore.Fakedb
I am trying to setup test framework for my Sitecore solution.
In that we are using fakedb to create the sitecore context.
We are getting below exception on a static function.
System....
0
votes
1
answer
231
views
Implement unit test for a sitecore MVC solution with glassmapper
I have the below scenario to implement unit testing on a Sitecore MVC (with glassmapper) integration.
We are using a wrapper class to make calls to Glassmapper Sitecore Context methods. Below is one ...
3
votes
1
answer
270
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 ...
0
votes
3
answers
329
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 ...
2
votes
1
answer
2k
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....
4
votes
1
answer
2k
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 ...
3
votes
1
answer
406
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 ...
1
vote
1
answer
398
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
{
...
3
votes
1
answer
74
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
1
answer
548
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
1
answer
681
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
1
answer
141
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
1
answer
835
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
1
answer
554
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
1
answer
949
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
1
answer
4k
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
1
answer
1k
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
1
answer
2k
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
1
answer
2k
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
2
answers
711
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
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 ...
5
votes
1
answer
620
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
1
answer
805
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
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: ...
3
votes
2
answers
549
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
2
answers
2k
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
3
answers
612
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("...