Coveo for sitecore within non-IIS hosted integration tests
We are trying to create some integration tests for our sitecore mvc.net project whereby from within MSTEST tests we instantiate a control and call its actions. So far we have sitecore api functionality working for some of our tests despite the non-existence of an http context.
However, we are running into some problems and exceptions with coveo libraries.
- We find that the methods that are supposed to return coveo field names with hash numbers on the end are returning the wrong numbers. This seems to be because the index names are not fully translated.
- Linq provider complains that no user has been provided.
Is there any documentation/guidance for getting the coveo sitecore libraries to behave during integration tests hosted outside of IIS, e.g. injecting in resources etc?
I'm afraid we don't have any documentation to suggest to you about integration tests with Coveo for Sitecore. We would really like to support it, but we have not yet fully explored the possibility so I can't provide any more help than what I know about our UI models.
As you might already know, we configured our models in Sitecore to use the default controller that instantiate a model and then calls the
Initialize(Rendering) method on the model.
You could instead try to use a custom controller that allows you to inject a configuration in the model.
SearchModel takes a
SearchModelConfiguration that has all the dependencies required to run the model.
If you could create a Mock of this configuration, this would allow you to handle your own user and bypass those context limitations.
Though I have not tested it and I am not sure that LINQ queries will be executed since they require a static context.
Good luck with the implementation! I really hope you manage to make it work, let us know if you successfully test it!