Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Inoshika Fernando 4 posts 74 karma points
    Oct 09, 2019 @ 20:35
    Inoshika Fernando
    0

    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.

  • Ismail Mayat 4366 posts 9472 karma points MVP 2x admin c-trib
    Oct 09, 2019 @ 20:50
    Ismail Mayat
    0

    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.

  • Inoshika Fernando 4 posts 74 karma points
    Oct 13, 2019 @ 21:17
    Inoshika Fernando
    0

    Do you have any example to show this? Sorry I'm new to umbraco

  • Ismail Mayat 4366 posts 9472 karma points MVP 2x admin c-trib
    Oct 14, 2019 @ 05:11
  • Inoshika Fernando 4 posts 74 karma points
    Oct 14, 2019 @ 20:10
    Inoshika Fernando
    0

    Thank you. I'll try that.

Please Sign in or register to post replies

Write your reply to:

Draft