November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If I were you, I'd isolate away the Find queries in your own ISearchService/SearchService or something, and inject that into your controllers. That way, you don't end up testing Find itself in any way, nor do you have to mock it. You simply mock your own wrapper of it, and inject that into your controllers.
Often, I see this as a good way to reuse queries over multiple places. And you can package all your search logic in there, which the controller really isn't interested in knowing ("should I search in field A and B, or include C and D too?").
Also, you can let your controllers just gather data and stack them into a view model, as they are intended to - and not do any "business logic" (as a search is, in a way) at all.
I have just publish a blog post on how tho do this, please read it and see if it might get you in the right direction
http://world.episerver.com/blogs/Henrik-Fransas/Dates/2015/1/how-to-do-unit-testing-on-episerver-find/
Hi,
I'm in the process writing unit tests for my MVC Controllers which uses EPiServer Find.
Has anyone tried to write unit tests around the GetContentResult extension? From what I understand it is not possible to mock extensions with MOQ. Any ideas how to make the code testable?
Much appreciated.
Thanks