Пример #1
0
        public void Random_ReturnsSequence()
        {
            // Set up
            CollectionContext <SimpleUser, List <SimpleUser> > context =
                new CollectionContext <SimpleUser, List <SimpleUser> >(
                    new List <IObjectGenerator <SimpleUser> >());

            ICollectionSequenceSelectionContext <SimpleUser, List <SimpleUser> > sequence = context.Random(10);

            Assert.NotNull(sequence);
        }
        public static ICollectionSequenceSelectionContext <TPoco, TCollection> SourceForPrivatePropety <TPoco, TCollection, TMember>(this ICollectionSequenceSelectionContext <TPoco, TCollection> context, Expression <Func <TPoco, TMember> > propertyExpr, IDatasource dataSource)
            where TCollection : ICollection <TPoco>
        {
            var member = ReflectionHelper.GetMember(propertyExpr);

            var collectionContext = (CollectionSequenceSelectionContext <TPoco, TCollection>)context;
            var generators        = (IEnumerable <IObjectGenerator <TPoco> >)collectionContext.GetFieldValue("mSelected", Flags.InstancePrivate);

            foreach (var generator in generators.OfType <ObjectGenerator <TPoco> >())
            {
                generator.AddAction(new PrivateMemberSetFromSourceAction(member, dataSource));
            }
            return(context);
        }