I'm using Umbraco v7 and trying to develop unit tests for search using ExamineManager. But I get following error.
Message:
System.Configuration.ConfigurationErrorsException : Exception has been thrown by the target of an invocation. (C:\Users\inoshika.fernando\source\trn-umbraco\NZME.Tests\bin\Debug\config\ExamineSettings.config line 12)
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace is
Stack Trace:
at ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
at ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
at ExamineManager.EnsureProviders() in ExamineManager.cs line: 111
at ExamineManager.getSearchProviderCollection() in ExamineManager.cs line: 75
at ExamineSingleBackgroundWingsStrategy.GetSingleBackgroundWingsModel(UmbracoHelper helper, IPublishedContent currentPage, String imageCdn) in ExamineSingleBackgroundWingsStrategy.cs line: 41
at ExamineSingleBackgroundWingsStrategyTest.ExamineShouldreturnSameBackgroundWings_Model(String image) in ExamineSingleBackgroundWingsStrategyTest.cs line: 117
at --TargetInvocationException
at RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at Activator.CreateInstance(Type type, Boolean nonPublic)
at Activator.CreateInstance(Type type)
at HttpRuntime.CreatePublicInstanceByWebObjectActivator(Type type)
at ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
at --NullReferenceException
at UmbracoContentIndexer.ctor()
This works fine in project. Only this issue comes in test environment.
Unit test in ExamineManager
Hi all,
I'm using Umbraco v7 and trying to develop unit tests for search using ExamineManager. But I get following error.
Message: System.Configuration.ConfigurationErrorsException : Exception has been thrown by the target of an invocation. (C:\Users\inoshika.fernando\source\trn-umbraco\NZME.Tests\bin\Debug\config\ExamineSettings.config line 12) ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace is Stack Trace: at ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType) at ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType) at ExamineManager.EnsureProviders() in ExamineManager.cs line: 111 at ExamineManager.getSearchProviderCollection() in ExamineManager.cs line: 75 at ExamineSingleBackgroundWingsStrategy.GetSingleBackgroundWingsModel(UmbracoHelper helper, IPublishedContent currentPage, String imageCdn) in ExamineSingleBackgroundWingsStrategy.cs line: 41 at ExamineSingleBackgroundWingsStrategyTest.ExamineShouldreturnSameBackgroundWings_Model(String image) in ExamineSingleBackgroundWingsStrategyTest.cs line: 117 at --TargetInvocationException at RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at Activator.CreateInstance(Type type, Boolean nonPublic) at Activator.CreateInstance(Type type) at HttpRuntime.CreatePublicInstanceByWebObjectActivator(Type type) at ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType) at --NullReferenceException at UmbracoContentIndexer.ctor()
This works fine in project. Only this issue comes in test environment.
Take a look at the examine codebase and tests in there to see how you could test queries.
Examine uses lucene and lucene does inmemoery directory so in theory you could fireup one of these and write queries to test.
I have not done it myself although i have done in memory tests for lucene.net.
Do you have any example to show this? Sorry I'm new to umbraco
Take a look in https://github.com/Shazwazza/Examine/tree/master/src/Examine.Test this is the test project for Examine also take a look here https://github.com/umbraco/Umbraco-CMS/tree/v8/dev/src/Umbraco.Tests/UmbracoExamine
Regards
Ismail
Thank you. I'll try that.
is working on a reply...