How to use IoC container for unit testing RRS feed

  • Question

  • Hi there,

    I am new to unit testing. I read an article about unit testing recently.

    It is said that "... Problems can arise from using constructors to inject implementations. If your code under test requires more than one stub to work correctly without dependencies, adding more and more constructors (or more and more constructor parameters) becomes a hassle, ...".

    It is also said that the IoC container can solve this problem.

    As far as I know, constructor injection is the third type of IoC.

    I want to know about the IoC container. How it works and how it solves the problem of constructor injection while unit testing.

    I got a implementation of the IoC container in C++ from this blog: http://www.codinginlondon.com/2009/05/cheap-ioc-in-native-c.html

    However, I don't get the concept yet.

    Does anyone have good sample code of the IoC container and sample code of how this container solve the unit testing problem?

    Thanks in advance.

    • Moved by Helen Zhao Monday, February 27, 2012 3:40 AM (From:Visual C++ General)
    Thursday, February 23, 2012 11:57 AM


All replies