public void OptionalDependencyParameterIsResolvedIfRegisteredInContainer()
        {
            ISomeInterface  expectedSomeInterface = new SomeInterfaceMock();
            IUnityContainer container             = new UnityContainer()
                                                    .RegisterInstance <ISomeInterface>(expectedSomeInterface);

            var result = container.Resolve <ObjectWithOptionalConstructorParameter>();

            Assert.AreSame(expectedSomeInterface, result.SomeInterface);
        }
        public void OptionalPropertiesAreInjectedWhenRegisteredInContainer()
        {
            ISomeInterface  expected  = new SomeInterfaceMock();
            IUnityContainer container = new UnityContainer()
                                        .RegisterInstance(expected);

            var result = container.Resolve <ObjectWithOptionalProperty>();

            Assert.AreSame(expected, result.SomeInterface);
        }
        public void OptionalDependencyParameterIsResolvedIfRegisteredInContainer()
        {
            ISomeInterface expectedSomeInterface = new SomeInterfaceMock();
            IUnityContainer container = new UnityContainer()
                .RegisterInstance<ISomeInterface>(expectedSomeInterface);

            var result = container.Resolve<ObjectWithOptionalConstructorParameter>();

            Assert.Same(expectedSomeInterface, result.SomeInterface);
        }
        public void OptionalPropertiesAreInjectedByName()
        {
            ISomeInterface namedSomeInterface   = new SomeInterfaceMock();
            ISomeInterface defaultSomeInterface = new SomeInterfaceMock();

            IUnityContainer container = new UnityContainer()
                                        .RegisterInstance <ISomeInterface>(defaultSomeInterface)
                                        .RegisterInstance <ISomeInterface>("named", namedSomeInterface);

            var result = container.Resolve <ObjectWithNamedOptionalProperty>();

            Assert.AreSame(namedSomeInterface, result.SomeInterface);
        }
        public void OptionalDependencyParameterIsResolvedByName()
        {
            ISomeInterface namedSomeInterface   = new SomeInterfaceMock();
            ISomeInterface defaultSomeInterface = new SomeInterfaceMock();

            IUnityContainer container = new UnityContainer()
                                        .RegisterInstance <ISomeInterface>(defaultSomeInterface)
                                        .RegisterInstance <ISomeInterface>("named", namedSomeInterface);

            var result = container.Resolve <ObjectWithNamedOptionalConstructorParameter>();

            Assert.AreSame(namedSomeInterface, result.SomeInterface);
        }
        public void OptionalPropertiesAreInjectedByName()
        {
            ISomeInterface namedSomeInterface = new SomeInterfaceMock();
            ISomeInterface defaultSomeInterface = new SomeInterfaceMock();

            IUnityContainer container = new UnityContainer()
                .RegisterInstance<ISomeInterface>(defaultSomeInterface)
                .RegisterInstance<ISomeInterface>("named", namedSomeInterface);

            var result = container.Resolve<ObjectWithNamedOptionalProperty>();

            Assert.Same(namedSomeInterface, result.SomeInterface);
        }
        public void OptionalDependencyParameterIsResolvedByName()
        {
            ISomeInterface namedSomeInterface = new SomeInterfaceMock();
            ISomeInterface defaultSomeInterface = new SomeInterfaceMock();

            IUnityContainer container = new UnityContainer()
                .RegisterInstance<ISomeInterface>(defaultSomeInterface)
                .RegisterInstance<ISomeInterface>("named", namedSomeInterface);

            var result = container.Resolve<ObjectWithNamedOptionalConstructorParameter>();

            Assert.Same(namedSomeInterface, result.SomeInterface);
        }
        public void OptionalPropertiesAreInjectedWhenRegisteredInContainer()
        {
            ISomeInterface expected = new SomeInterfaceMock();
            IUnityContainer container = new UnityContainer()
                .RegisterInstance(expected);

            var result = container.Resolve<ObjectWithOptionalProperty>();

            Assert.Same(expected, result.SomeInterface);
        }