Beispiel #1
0
        public void BindingsAreRemovedWhenModulesAreUnloaded()
        {
            var moduleA = new MockModuleA();
            var moduleB = new MockModuleB();

            using (var kernel = new StandardKernel(moduleA, moduleB))
            {
                var one = kernel.Get <IServiceA>();
                Assert.That(one, Is.Not.Null);
                Assert.That(one, Is.InstanceOfType(typeof(ServiceImplA)));

                var two = kernel.Get <IServiceB>();
                Assert.That(two, Is.Not.Null);
                Assert.That(two, Is.InstanceOfType(typeof(ServiceImplB)));

                kernel.Unload(moduleA);
                Assert.That(kernel.Components.BindingRegistry.HasBinding(typeof(IServiceA)), Is.False);
            }
        }
Beispiel #2
0
		public void BindingsAreRemovedWhenModulesAreUnloaded()
		{
			var moduleA = new MockModuleA();
			var moduleB = new MockModuleB();

			using (var kernel = new StandardKernel(moduleA, moduleB))
			{
				var one = kernel.Get<IServiceA>();
				Assert.That(one, Is.Not.Null);
				Assert.That(one, Is.InstanceOfType(typeof(ServiceImplA)));

				var two = kernel.Get<IServiceB>();
				Assert.That(two, Is.Not.Null);
				Assert.That(two, Is.InstanceOfType(typeof(ServiceImplB)));

				kernel.Unload(moduleA);
				Assert.That(kernel.Components.BindingRegistry.HasBinding(typeof(IServiceA)), Is.False);
			}
		}