示例#1
0
        public void OptionalParametersNotResolvedIfMoreSpecificTypeRegisteredWithName()
        {
            IUnityContainer container = new UnityContainer();
            var             input     = new TestObject();

            container.RegisterInstance <TestObject>("test", input);

            NamedOptionalConstParameterClass result = container.Resolve <NamedOptionalConstParameterClass>();

            Assert.IsNull(result.TestObject);
        }
示例#2
0
        public void OptionalParametersResolvedIfInstanceRegisteredWithName()
        {
            IUnityContainer container = new UnityContainer();
            var             input     = new TestObject();

            container.RegisterInstance <ITestObject>("test", input);

            NamedOptionalConstParameterClass result = container.Resolve <NamedOptionalConstParameterClass>();

            Assert.AreSame(input, result.TestObject);
        }
示例#3
0
        public void OptionalParametersResolvedIfInstanceRegisteredInParentWithName()
        {
            IUnityContainer parent = new UnityContainer();
            IUnityContainer child  = parent.CreateChildContainer();

            var input = new TestObject();

            parent.RegisterInstance <ITestObject>("test", input);

            NamedOptionalConstParameterClass result = child.Resolve <NamedOptionalConstParameterClass>();

            Assert.AreSame(input, result.TestObject);
        }