Пример #1
0
        protected IEnumerable <IQueryConstraintProvider> Wrap(IncludeExpression includeExpression)
        {
            var expressionsInScope = new List <ExpressionInScope>
            {
                new ExpressionInScope(null, includeExpression)
            };

            var mock = new Mock <IQueryConstraintProvider>();

            mock.Setup(provider => provider.GetConstraints()).Returns(expressionsInScope);

            IQueryConstraintProvider includeConstraintProvider = mock.Object;

            return(includeConstraintProvider.AsEnumerable());
        }
Пример #2
0
        private IEnumerable <IQueryConstraintProvider> GetIncludeConstraints(IEnumerable <IEnumerable <RelationshipAttribute> > inclusionChains = null)
        {
            var expressionsInScope = new List <ExpressionInScope>();

            if (inclusionChains != null)
            {
                var chains            = inclusionChains.Select(relationships => new ResourceFieldChainExpression(relationships.ToArray())).ToList();
                var includeExpression = IncludeChainConverter.FromRelationshipChains(chains);
                expressionsInScope.Add(new ExpressionInScope(null, includeExpression));
            }

            var mock = new Mock <IQueryConstraintProvider>();

            mock.Setup(x => x.GetConstraints()).Returns(expressionsInScope);

            IQueryConstraintProvider includeConstraintProvider = mock.Object;

            return(includeConstraintProvider.AsEnumerable());
        }