示例#1
0
            public void OverridesHowKernelIsCreated()
            {
                Func <IKernel> creator = () => {
                    return(new FakeKernel());
                };

                KernelManager.SetKernelResolver(creator);
                IKernel kernel = KernelManager.GetKernel();

                Assert.AreEqual(@"fainting.goat.tests.FakeKernel", kernel.GetType().FullName);
            }
示例#2
0
        public MvcApplication()
        {
            if (MvcApplication.Kernel == null)
            {
                lock (KernelLock) {
                    if (MvcApplication.Kernel == null)
                    {
                        MvcApplication.Kernel = this.RegisterNinject();

                        KernelManager.SetKernelResolver(() => { return(MvcApplication.Kernel); });
                    }
                }
            }
        }
示例#3
0
            public void SettingToNullGoesBackToDefault()
            {
                Func <IKernel> creator = () => {
                    return(new FakeKernel());
                };

                KernelManager.SetKernelResolver(creator);
                IKernel kernel = KernelManager.GetKernel();

                Assert.AreEqual(@"fainting.goat.tests.FakeKernel", kernel.GetType().FullName);

                // set to null to get default behavior
                KernelManager.SetKernelResolver(null);

                kernel = KernelManager.GetKernel();
                Assert.IsNotNull(kernel);

                Assert.AreEqual(@"Ninject.StandardKernel", kernel.GetType().FullName);
            }