In my model project, I have a service interface IMyService and default implementation DefaultMyService. This service is used by my entities.

In my unit tests, I would like to create a different implementation (TestMyService), and my entities should use that implementation during the unit tests.

How can I instruct the IoC container to return TestMyService in my unit tests?

asked Jan 19 '11 at 19:25

ara's gravatar image

ara
395858791

Currently, we are investigating the case. It might take a while.

(Jan 20 '11 at 05:50) Dmitri Maximov Dmitri%20Maximov's gravatar image

One Answer:

Hello Ara,

For now, there is no any option to set a service implementation as default one. But there is a solution that will definitely work.

As you know, in domain configuration you can register an assembly or a part of an assembly, limited by a namespace, or two, or many. So, I'd recommend you to move each of these two services into separate namespaces and register required namespace depending on the environment you are using (production, testing).

Hope that helps.

answered Jan 20 '11 at 10:10

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

I'll post on how to configure services through app.config soon.

(Jan 24 '11 at 10:10) Dmitri Maximov Dmitri%20Maximov's gravatar image

Hi Dmitri, any update on this?

(Mar 08 '12 at 22:56) ara ara's gravatar image

Making a sample for you...

(Mar 13 '12 at 06:45) Dmitri Maximov Dmitri%20Maximov's gravatar image

Ara,

I've uploaded the sample about manual service registration to our new sample repository. Hope that helps.

(Mar 16 '12 at 11:04) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×5
×3

Asked: Jan 19 '11 at 19:25

Seen: 2,362 times

Last updated: Mar 16 '12 at 11:04

powered by OSQA