public void ReturnsNullWhenPassedNull()
        {
            MockBuilderContext     ctx      = new MockBuilderContext();
            PropertySetterStrategy strategy = new PropertySetterStrategy();

            Assert.IsNull(strategy.BuildUp <object>(ctx, null, null));
        }
        public void IncompatibleTypesThrow()
        {
            MockBuilderContext     ctx      = new MockBuilderContext();
            PropertySetterStrategy strategy = new PropertySetterStrategy();

            PropertySetterPolicy policy = new PropertySetterPolicy();

            policy.Properties.Add("Foo", new PropertySetterInfo("Foo", new ValueParameter <object>(new object())));
            ctx.Policies.Set <IPropertySetterPolicy>(policy, typeof(MockInjectionTarget), null);

            MockInjectionTarget target = new MockInjectionTarget();

            strategy.BuildUp <MockInjectionTarget>(ctx, target, null);
        }
        public void ThrowsIfPropertyInjectedIsReadOnly()
        {
            MockBuilderContext     ctx      = new MockBuilderContext();
            PropertySetterStrategy strategy = new PropertySetterStrategy();

            PropertySetterPolicy policy1 = new PropertySetterPolicy();

            policy1.Properties.Add("Bar", new PropertySetterInfo("Bar", new ValueParameter <string>("value for foo")));
            ctx.Policies.Set <IPropertySetterPolicy>(policy1, typeof(MockInjectionTarget), null);

            MockInjectionTarget target = new MockInjectionTarget();

            strategy.BuildUp <object>(ctx, target, null);
        }
        public void InjectionIsBasedOnConcreteTypeNotRequestedType()
        {
            MockBuilderContext     ctx      = new MockBuilderContext();
            PropertySetterStrategy strategy = new PropertySetterStrategy();

            PropertySetterPolicy policy1 = new PropertySetterPolicy();

            policy1.Properties.Add("Foo", new PropertySetterInfo("Foo", new ValueParameter <string>("value for foo")));
            ctx.Policies.Set <IPropertySetterPolicy>(policy1, typeof(MockInjectionTarget), null);

            MockInjectionTarget target = new MockInjectionTarget();

            strategy.BuildUp <object>(ctx, target, null);

            Assert.AreEqual("value for foo", target.Foo);
        }