Exemple #1
0
        public void NoInstance()
        {
            Spy.PropertyValue = null;
            object                 obj      = new object();
            MockBuilderContext     context  = new MockBuilderContext();
            PropertySetterStrategy strategy = new PropertySetterStrategy();
            PropertySetterPolicy   policy   = new PropertySetterPolicy();

            policy.Properties.Add(new ReflectionPropertySetterInfo(typeof(Spy).GetProperty("Property"), new ValueParameter <object>(obj)));
            context.Policies.Set <IPropertySetterPolicy>(policy, typeof(Spy));

            strategy.BuildUp(context, typeof(Spy), null);

            Assert.Null(Spy.PropertyValue);
        }
        protected override void AddParametersToPolicy(IBuilderContext context,
                                                      object buildKey,
                                                      IMemberInfo <PropertyInfo> member,
                                                      IEnumerable <IParameter> parameters)
        {
            IPropertySetterPolicy result = context.Policies.Get <IPropertySetterPolicy>(buildKey);

            if (result == null)
            {
                result = new PropertySetterPolicy();
                context.Policies.Set(result, buildKey);
            }

            foreach (IParameter parameter in parameters)
            {
                result.Properties.Add(new ReflectionPropertySetterInfo(member.MemberInfo, parameter));
            }
        }