Unit testing- How to inject services

Vote:
 

Hi,

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.

#145255
Mar 01, 2016 9:24
Vote:
 

There is a good guide here 

http://tedgustaf.com/blog/2013/10/unit-testing-in-episerver-7/

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

#145257
Mar 01, 2016 9:41
Vote:
 

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

#145260
Mar 01, 2016 10:01
Vote:
 

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.

#145264
Mar 01, 2016 11:55
Vote:
 

Thanks Daniel

#145269
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.