Ejemplo n.º 1
0
        private void AssertSqlMatches <TBase, TProjection>(string expected, IProjectedSelectQuery <TBase, TProjection> projectedSelectQuery)
            where TBase : class, new()
        {
            var selectWriter  = this.GetSql2012Writer();
            var concreteQuery = (ProjectedSelectQuery <TBase, TProjection>)projectedSelectQuery;
            var sqlResult     = selectWriter.GenerateSql(concreteQuery);

            this.outputHelper.WriteLine(sqlResult.Sql);
            Assert.Equal(expected, sqlResult.Sql);
        }
Ejemplo n.º 2
0
        private void AssertMapperMatches <TBase, TProjection>(object[] inputs, Type[] types, IProjectedSelectQuery <TBase, TProjection> projectedSelectQuery, params Action <TProjection>[] assertions)
            where TBase : class, new()
        {
            var selectWriter       = this.GetSql2012Writer();
            var concreteQuery      = (ProjectedSelectQuery <TBase, TProjection>)projectedSelectQuery;
            var sqlResult          = selectWriter.GenerateSql(concreteQuery);
            var projectionRewriter = new ProjectionExpressionRewriter <TBase, TProjection>(selectWriter.Configuration, concreteQuery, sqlResult.FetchTree);
            var result             = projectionRewriter.Rewrite();

            Assert.Equal(types, result.Types);
            var projection = result.Mapper(inputs);

            foreach (var assertion in assertions)
            {
                assertion(projection);
            }
        }