示例#1
0
        public void RegisterInstance_Valid()
        {
            var helper   = new UnityHelper();
            var instance = new TestClass1()
            {
                Name = "test"
            };

            var container = new UnityContainer();

            Assert.IsFalse(container.IsRegistered(typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.IsRegistered(typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Resolve <ITestInterface>());
        }
示例#2
0
        public void RegisterInstance_Valid()
        {
            var helper   = new NinjectHelper();
            var instance = new TestClass1()
            {
                Name = "test"
            };

            var container = new StandardKernel();

            Assert.IsFalse(GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(GetRegistrationInfo(container, typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Get <ITestInterface>());
        }
示例#3
0
        public void RegisterInstance_Valid()
        {
            var helper   = new WindsorHelper();
            var instance = new TestClass1()
            {
                Name = "test"
            };

            var container = new WindsorContainer();

            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.Resolve <ITestInterface>() != null);
            Assert.AreEqual(instance, container.Resolve <ITestInterface>());
        }
示例#4
0
        public void RegisterInstance_Valid()
        {
            var helper   = new MefHelper();
            var instance = new TestClass1()
            {
                Name = "test"
            };

            var container = new CompositionContainer();

            Assert.IsFalse(container.GetRegistrationInfo(typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.GetRegistrationInfo(typeof(ITestInterface)));
            Assert.AreEqual(instance, container.ResolveType <ITestInterface>());
        }
示例#5
0
        public void RegisterInstance_Valid()
        {
            var helper = new WindsorHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new WindsorContainer();
            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.Resolve<ITestInterface>() != null);
            Assert.AreEqual(instance, container.Resolve<ITestInterface>());
        }
示例#6
0
        public void RegisterInstance_Valid()
        {
            var helper = new UnityHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new UnityContainer();
            Assert.IsFalse(container.IsRegistered(typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.IsRegistered(typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Resolve<ITestInterface>());
        }
示例#7
0
        public void RegisterInstance_Valid()
        {
            var helper = new NinjectHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new StandardKernel();
            Assert.IsFalse(GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(GetRegistrationInfo(container, typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Get<ITestInterface>());
        }