public void Enact(IGenerationContext context, object target)
 {
     if (_member.IsField)
     {
         var generationContext = new GenerationContext(context.Builders, new TypeFieldGenerationContextNode((TypeGenerationContextNode)context.Node, (EngineTypeFieldMember)_member));
         var value             = _datasource.Next(generationContext);
         ((EngineTypeFieldMember)_member).FieldInfo.Set(target, value);
     }
     else
     {
         var generationContext = new GenerationContext(context.Builders, new TypePropertyGenerationContextNode((TypeGenerationContextNode)context.Node, (EngineTypePropertyMember)_member));
         var value             = _datasource.Next(generationContext);
         ((EngineTypePropertyMember)_member).PropertyInfo.Set(target, value);
     }
 }
        public void Enact(IGenerationContext context, object target)
        {
            var fieldContext = new GenerationContext(context.Builders, new TypeFieldGenerationContextNode(
                                                         (TypeGenerationContextNode)context.Node,
                                                         mMember));

            mMember.FieldInfo.SetValue(target, mDatasource.Next(fieldContext));
        }
Esempio n. 3
0
        public void Enact(IGenerationContext context, object target)
        {
            var propertyContext = new GenerationContext(context.Builders, new TypePropertyGenerationContextNode(
                                                            (TypeGenerationContextNode)context.Node,
                                                            mMember));

            mMember.PropertyInfo.SetValue(target, mDatasource.Next(propertyContext), null);
        }
Esempio n. 4
0
        public override IEnumerable <T> Next(IGenerationContext context)
        {
            var count = mRandom.Next(mMinCount, mMaxCount + 1);

            for (var i = 0; i < count; i++)
            {
                yield return((T)mSource.Next(context));
            }
        }
Esempio n. 5
0
        public void SetValue_SetsValueDataSource()
        {
            IEngineConfigurationDatasource source = null;

            mMemberMock.Setup(x => x.SetDatasource(It.IsAny <IEngineConfigurationDatasource>())).Callback((IEngineConfigurationDatasource configSource) =>
            {
                source = configSource;
            });
            mContext.SetValue(10);
            IDatasource datasource = source.Build();

            Assert.AreEqual(10, datasource.Next(null));
        }
        public Object CreateObject(IGenerationContext context)
        {
            Object createdObject = null;

            if (mFactory != null)
            {
                createdObject = mFactory.Next(context);
            }
            else
            {
                createdObject = Activator.CreateInstance(this.InnerType);
            }

            // Don't set it up if we've reached recursion limit
            if (context.Depth < context.Builders.RecursionLimit)
            {
                EnactActionsOnObject(context, createdObject);
            }
            return(createdObject);
        }