コード例 #1
0
        public void BuildSqlFilter_GivenSearchConditionTransformation_CustomFilterExpression(FilterType filterType, string expectedSqlExpression)
        {
            ReportFilter filter = new ReportFilter()
            {
                Value        = "a",
                Type         = filterType,
                ReportColumn = new ReportColumn
                {
                    Title = "First Field",
                    SqlValueExpression            = "TestTable.fField",
                    SearchConditionTransformation = (fValue, y, parameterName) =>
                    {
                        string result = string.Empty;

                        switch (y)
                        {
                        case FilterType.Equal:
                            result = parameterName + " = " + fValue;
                            break;

                        case FilterType.NotEqual:
                            result = parameterName + " != " + fValue;
                            break;
                        }

                        return(result);
                    }
                },
            };

            var sqlFilter = filter.BuildSqlFilter("@p0");

            Assert.That(sqlFilter, Is.EqualTo(expectedSqlExpression));
        }
コード例 #2
0
        public void BuildSqlFilter_SearchConditionTransformationNotProvided_DefaultFilterExpression(FilterType filterType, string expectedSqlExpression)
        {
            ReportFilter filter = new ReportFilter()
            {
                Type         = filterType,
                ReportColumn = new ReportColumn
                {
                    Title = "First Field",
                    SqlValueExpression = "TestTable.fField",
                },
            };

            var sqlFilter = filter.BuildSqlFilter("@p0");

            Assert.That(sqlFilter, Is.EqualTo(expectedSqlExpression));
        }