Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Unit testing- How to inject services



I am trying to implement some unit tests on EpiServer 8.11. I'm using Moq, and I've found FakeMaker which seems to be awesome. My question is, how can I configure my test project to inject all my services.

Mar 01, 2016 9:24

There is a good guide here

You need to play around with structure map and mocking framework some :)

Mar 01, 2016 9:41

Hi Daniel,

Thanks for reply. I can add all services and mock special features that I need.

I just wonder if I can load the other services that I don't need to mock by injection.

Using FakeMaker, I can create almost all of my EpiServer's structure and I just need to mock methods that use EpiServer or its data, after that I can test everything, including big services

Mar 01, 2016 10:01

Best way I know is to dotPeek Episerver.Global and look for IInitializableModule and copy those configurations and use them to set up "real" Episerver mappings. Version 2 is to avoid using dependencies to those in code and have a separate abstraction layer above them which are easier to mock. If you are using real calls to Episerver it will be more of an integration test of course.

Mar 01, 2016 11:55

Thanks Daniel

Mar 01, 2016 12:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.