public void CanBuildUpExistingObjectOnTypeWithCtorWithRefParameter()
        {
            IUnityContainer container =
                new UnityContainer()
                    .RegisterType<TypeWithConstructorWithRefParameter>(new InjectionProperty("Property", 10));
            string ignored = "ignored";
            TypeWithConstructorWithRefParameter instance = new TypeWithConstructorWithRefParameter(ref ignored);

            container.BuildUp(instance);

            Assert.AreEqual(10, instance.Property);
        }
Example #2
0
        public void CanBuildUpExistingObjectOnTypeWithCtorWithRefParameter()
        {
            IUnityContainer container =
                new UnityContainer()
                .RegisterType <TypeWithConstructorWithRefParameter>(new InjectionProperty("Property", 10));
            string ignored = "ignored";
            TypeWithConstructorWithRefParameter instance = new TypeWithConstructorWithRefParameter(ref ignored);

            container.BuildUp(instance);

            Assert.AreEqual(10, instance.Property);
        }
Example #3
0
        public void ResolvingANewInstanceOfTypeWithCtorWithRefParameterThrows()
        {
            IUnityContainer container = new UnityContainer();

            try
            {
                TypeWithConstructorWithRefParameter instance = container.Resolve <TypeWithConstructorWithRefParameter>();
                Assert.Fail("should have thrown");
            }
            catch (ResolutionFailedException)
            {
                // expected
            }
        }
        public void ResolvingANewInstanceOfTypeWithCtorWithRefParameterThrows()
        {
            IUnityContainer container = new UnityContainer();

            Assert.Throws <ResolutionFailedException>(() => { TypeWithConstructorWithRefParameter instance = container.Resolve <TypeWithConstructorWithRefParameter>(); });
        }