Esempio n. 1
0
        public static void Check(QueryTestDescription <TModel> tester, Expression rewrittenQuery)
        {
            var assertingVisitor = new AssertingCriteriaVisitor <TModel>(tester);

            assertingVisitor.Visit(rewrittenQuery);
            Assert.IsTrue(assertingVisitor.FoundMatch, "Found no expression for {0}.\nFound: {1}".InvariantFormat(tester.ToString(), assertingVisitor.MatchesFound));
        }
Esempio n. 2
0
 public static QueryTestDescription <TModel> WithField <TModel>(this QueryTestDescription <TModel> queryTestDescription, params FieldPredicateExpression[] expectedFieldExpressions)
 {
     foreach (var fieldPredicateExpression in expectedFieldExpressions)
     {
         queryTestDescription.Fields.Add(fieldPredicateExpression);
     }
     return(queryTestDescription);
 }
Esempio n. 3
0
 public static QueryTestDescription <TModel> WithSchema <TModel>(this QueryTestDescription <TModel> queryTestDescription, params SchemaPredicateExpression[] expectedSchemaExpressions)
 {
     foreach (var schemaExpression in expectedSchemaExpressions)
     {
         queryTestDescription.Schemas.Add(schemaExpression);
     }
     return(queryTestDescription);
 }
Esempio n. 4
0
        public void Run(QueryTestDescription <TModel> onItem)
        {
            // Arrange
            var nullQueryableDataSource = new NullQueryableDataSource();
            var context      = GenerateContext <TModel>(nullQueryableDataSource);
            var dynamicQuery = onItem.OriginalExpression as Expression <Func <TModel, bool> >;

            dynamic test = new ExpandoObject();

            test.colour = "orange";

            dynamic test2 = new BendyObject();

            test2.colour = "orange";

            var query = context.Where(dynamicQuery ?? onItem.OriginalQuery);

            // Act
            query.ToList();
            var generatedQuery = nullQueryableDataSource.GeneratedQueryDescription;

            // Assert
            AssertingCriteriaVisitor <TModel> .Check(onItem, generatedQuery.Criteria);
        }
Esempio n. 5
0
 public AssertingCriteriaVisitor(QueryTestDescription <TModel> tester)
 {
     _tester = tester;
 }
Esempio n. 6
0
 public void RunExtras(QueryTestDescription <TModel> item)
 {
     Run(item);
 }