Esempio n. 1
0
        public void TypeBasedOverrideConstructorWithNullOverride()
        {
            TypeToInject2ForTypeOverride defaultValue  = new TypeToInject2ForTypeOverride(111);
            TypeToInject2ForTypeOverride overrideValue = null;

            AssertHelper.ThrowsException <ArgumentNullException>(() => new ParameterOverride("injectedObject", overrideValue));
        }
Esempio n. 2
0
        public void TypeBasedOverrideWithConstructorExactTypeMatch()
        {
            TypeToInject2ForTypeOverride defaultValue      = new TypeToInject2ForTypeOverride(111);
            TypeToInject2ForTypeOverride overrideValue     = new TypeToInject2ForTypeOverride(222);
            ParameterOverride            overrideParam     = new ParameterOverride("injectedObject", overrideValue);
            TypeBasedOverride            overrideDecorator = new TypeBasedOverride(typeof(TypeToToUndergoeTypeBasedInject2), overrideParam);

            IUnityContainer container = new UnityContainer();

            container.RegisterType <IForToUndergoeInject, TypeToToUndergoeTypeBasedInject2>(new InjectionConstructor(defaultValue));
            var result = container.Resolve <IForToUndergoeInject>(overrideDecorator);

            Assert.AreEqual <int>(222, result.IForTypeToInject.Value);
        }
Esempio n. 3
0
        public void TypeBasedOverrideWithConstructorExactTypeMatch()
        {
            TypeToInject2ForTypeOverride defaultValue = new TypeToInject2ForTypeOverride(111);
            TypeToInject2ForTypeOverride overrideValue = new TypeToInject2ForTypeOverride(222);
            ParameterOverride overrideParam = new ParameterOverride("injectedObject", overrideValue);
            TypeBasedOverride overrideDecorator = new TypeBasedOverride(typeof(TypeToToUndergoeTypeBasedInject2), overrideParam);

            IUnityContainer container = new UnityContainer();

            container.RegisterType<IForToUndergoeInject, TypeToToUndergoeTypeBasedInject2>(new InjectionConstructor(defaultValue));
            var result = container.Resolve<IForToUndergoeInject>(overrideDecorator);

            Assert.AreEqual<int>(222, result.IForTypeToInject.Value);
        }
Esempio n. 4
0
 public void TypeBasedOverrideConstructorWithNullOverride()
 {
     TypeToInject2ForTypeOverride defaultValue = new TypeToInject2ForTypeOverride(111);
     TypeToInject2ForTypeOverride overrideValue = null;
     AssertHelper.ThrowsException<ArgumentNullException>(() => new ParameterOverride("injectedObject", overrideValue));
 }