Exemple #1
0
        public void TypeBasedOverrideConstructorWithNullOverride()
        {
            TypeToInject2ForTypeOverride defaultValue  = new TypeToInject2ForTypeOverride(111);
            TypeToInject2ForTypeOverride overrideValue = null;

            AssertHelper.ThrowsException <ArgumentNullException>(() => new ParameterOverride("injectedObject", overrideValue));
        }
Exemple #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);
        }
        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);
        }
 public void TypeBasedOverrideConstructorWithNullOverride()
 {
     TypeToInject2ForTypeOverride defaultValue = new TypeToInject2ForTypeOverride(111);
     TypeToInject2ForTypeOverride overrideValue = null;
     AssertHelper.ThrowsException<ArgumentNullException>(() => new ParameterOverride("injectedObject", overrideValue));
 }