November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
My guess is that SearchClient.Instance needs a web context which you dont have when running a unit test?
If mocking is an option for your test you could use IClient in your Web API contoller, as SearchClient.Instance is an implementation of IClient
@helani: This post should help you on your way: https://world.episerver.com/blogs/Henrik-Fransas/Dates/2015/1/how-to-do-unit-testing-on-episerver-find/
I have a Web API controller which use Epi Find to get data and it works perfectly in the website, but fails the MS unit test with following exception: "The type initializer for 'EPiServer.Find.Framework.SearchClient' threw an exception". The exception is thrown at this statement:
var client = SearchClient.Instance;
What is the reason that the SearchClient.Instance is not working when the unit TestMethod call the Controller Get method? and how to fix it?