2

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.ConfigurationException: 'Could not create instance of type: Sitecore.Data.Managers.ItemProvider. No matching constructor was found.'

**Stack Trace:**

   at Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
   at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, Boolean assert)
   at Sitecore.Configuration.DefaultFactory.GetProviders[TProvider,TCollection](List`1 nodes)
   at Sitecore.Configuration.DefaultFactory.GetProviders[TProvider,TCollection](String rootPath, TProvider& defaultProvider)
   at Sitecore.Configuration.ProviderHelper`2.ReadProviders()
   at Sitecore.Configuration.ProviderHelper`2.get_Provider()
   at Sitecore.Data.Managers.DefaultItemManager.get_FallbackProvider()
   at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database, SecurityCheck securityCheck)
   at Sitecore.Data.Managers.DefaultItemManager.GetItem(String itemPath, Language language, Version version, Database database)
   at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)

1 Answer 1

2

There is a list of breaking changes between Sitecore 9.2 and 9.3 so you have to upgrade FakeDb to v3 (see release notes).

JFI, for 9.3 FakeDb is no longer needed. You can easily mock Sitecore API.

4
  • Thank you so much for your detail.
    – BalaSM
    Jun 2, 2020 at 13:17
  • Can we use Moq for Item Axes? I have converted to my code from Nsubstitue to Moq. Nsubstitue: var item = Substitute.For<Item>(id, itemData, database); item.Axes.Returns(Substitute.For<ItemAxes>(item)); return item; Moq: var item = new Mock<Item>(id, itemData, database); item.Axes.Returns(new Mock<ItemAxes>(item)); return item; I am getting error in Moq.
    – BalaSM
    Jun 3, 2020 at 18:43
  • How it's related to the current question? I suggest you to create a new question and show your code. Jun 3, 2020 at 18:47
  • Thank you so much for your guidance!!!
    – BalaSM
    Jun 3, 2020 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.