Пример #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));
        }
Пример #2
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);
        }