dependency injection - Resetting an IKernel in Ninject v1 -


I'm experiencing a problem with Nin1's V1 and resetting StandardCernel. I have a static object that I use to provide access to the kernel such as

  public static class ObjectFactory {Private static IKernel _ kernel = new standard kernel (new CanceisModule ()); // Summary Public static zero reset () {_kernel = null; _kernel = New standard kernel (new CanceisModule ()); }}  

The problem comes when I try to use the object factor in various unit tests (I use MSTE) or in fitness fixtures. I always call the ObjectFactory.Reset () method before every new test or stability, but sometimes it looks like a reset that does not really work and leaves the original binding in place I know that There is one way to reset the IKernel objects in vinux of Ninject, but we are not ready to make this step yet (and this is a very important step for us).

Can someone advise you why this could happen? I'm guessing that this is related to how different runners perform different tests on different threads, but how do I avoid it?

Thank you in advance

Your attitude looks okay.

In general, the test runner does not run multi-threaded or some magic as you anticipate. / P>

I suggest debugging my tests by putting a breakpop in my reset ().

In your code, there is a non-static method in a stable category, so leaving something else to mention what you are doing?

When you say "new test or stability", then what is it? Often, you are using Ninegigings in tests, it is better to keep the kernel in the base class, and make sure that even though an object is dependent on the factual singleton, reset it at the right time to avoid any confusion or suspicion.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -