I am writing unit test to read from ContentSearchManager.GetIndex method. At line ContentSearchManager.GetIndex(indexableItem) in below code :

        Sitecore.Context.SetActiveSite("<<Site name>>");

        // Pull the start path of the site
        string startPath = Sitecore.Context.Site.StartPath;

        // Pull the database name
        string databaseName = Sitecore.Context.Site.Database.Name;

        // Load the web database, and get item
        var db = Sitecore.Data.Database.GetDatabase("web");

        var item = db.GetItem("<<bucket item>>");
        var indexableItem = (SitecoreIndexableItem)item;
        var index = ContentSearchManager.GetIndex(indexableItem);

I am getting error

Service Sitecore.Abstractions.ICorePipeline was not registered in container

Complete stack trace message is :

at Sitecore.ContentSearch.Abstractions.ObjectLocator.GetInstance[TService]()
   at Sitecore.ContentSearch.ContentSearchManager.GetContextIndexName(IIndexable indexable)
   at Sitecore.ContentSearch.ContentSearchManager.GetIndex(IIndexable indexable)
   at MyRadiometerTest.Services.SimpleTests.asset_that_search_working() 
   in C:\CM\Project\RadiometerUnitTest\MyRadiometerTest\Services\ContextTest.cs:line 70

Please suggest if anyone has fixed such issue or has idea about it.

Thanks, Chandana

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.