public void CanBuildUpExistingObjectOnTypeWithCtorWithOutParameter()
        {
            IUnityContainer container =
                new UnityContainer()
                    .RegisterType<TypeWithConstructorWithOutParameter>(new InjectionProperty("Property", 10));
            string ignored = "ignored";
            TypeWithConstructorWithOutParameter instance = new TypeWithConstructorWithOutParameter(out ignored);

            container.BuildUp(instance);

            Assert.AreEqual(10, instance.Property);
        }
Beispiel #2
0
        public void CanBuildUpExistingObjectOnTypeWithCtorWithOutParameter()
        {
            IUnityContainer container =
                new UnityContainer()
                .RegisterType <TypeWithConstructorWithOutParameter>(new InjectionProperty("Property", 10));
            string ignored = "ignored";
            TypeWithConstructorWithOutParameter instance = new TypeWithConstructorWithOutParameter(out ignored);

            container.BuildUp(instance);

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

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

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