public Global() { // We create an instance of OnePerRequestModule and initialize it with our HttpApplication so it can handle // deactivation of instances created via the Kernel when the Http request is done this.onePerRequestModule = new OnePerRequestModule(); this.onePerRequestModule.Init(this); }
public void InstancesAreDisposedViaOnePerRequestModule() { var settings = new NinjectSettings { CachePruningInterval = TimeSpan.MaxValue }; var kernel = new StandardKernel(settings); kernel.Bind<ITool>().To<Hammer>().InRequestScope(); StartNewHttpRequest(); var instance = kernel.Get<ITool>(); instance.ShouldNotBeNull(); instance.ShouldBeInstanceOf<Hammer>(); var opr = new OnePerRequestModule(); opr.DeactivateInstancesForCurrentHttpRequest(); instance.IsDisposed.ShouldBeTrue(); }