views:

22

answers:

1

Just looking for some advice really. I've had to write some integration tests to test some BL I need to access (later from the web app) and I have configured them to use singleton life-cycle.

I will use in the web application 'PerWebRequest'. Just really assessing whether or not this is a good thing to do? or if it matters?

+1  A: 

It may matter. It's difficult to give a definite answer from the information provide, since it's not entirely clear which parts of the application you are looking to integrate - i.e. if you are not using the web application in your integration test, PerWebRequest makes no sense.

Although Singleton is the default lifetime style in Windsor, it may be problematic for some components in some scenarios (Entity Framework object contexts in web applications come to mind).

The Transient lifestyle might be a good alternative if you don't care too much about performance in your integration test (and even so, you may not feel that big of a difference). However, some components are intended to be long-lived, so it wouldn't fit all components.

Try it out and see what works. If you are in doubt, this would be another area where the integration test may bring you more clarity.

Mark Seemann
Thanks for responding - I tried what you suggested and it worked out fine.
Aim Kai

related questions