コード例 #1
0
        public void TestMaxRecords(DatabaseProviderTestCase tc)
        {
            var databaseServices = tc.Services;
            var sqlExecutor      = new SQLExecutor(databaseServices);

            int maxRecordsValue = 1;
            IDictionary <SelectPlaceholder, string> maxRecordsPlaceholders = databaseServices.DMLService.Queries.SQLPlaceholderValuesForMaxRecords(maxRecordsValue.ToString());
            string beforeStatement = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeStatement);
            string afterSelect     = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterSelectKeyword);
            string beforeFrom      = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeFromKeyword);
            string afterFrom       = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterFromKeyword);
            string beforeWhere     = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeWhereKeyword);
            string afterWhere      = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterWhereKeyword);
            string beforeGroupBy   = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeGroupByKeyword);
            string afterGroupBy    = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterGroupByKeyword);
            string beforeHaving    = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeHavingKeyword);
            string afterHaving     = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterHavingKeyword);
            string beforeOrderBy   = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.BeforeOrderByKeyword);
            string afterOrderBy    = maxRecordsPlaceholders.GetPlaceholderValueTrimStart(SelectPlaceholder.AfterOrderByKeyword);
            string afterStatement  = maxRecordsPlaceholders.GetPlaceholderValueTrimEnd(SelectPlaceholder.AfterStatement);

            string sql = beforeStatement +
                         "SELECT " + afterSelect + "NAME " +
                         beforeFrom + "FROM " + afterFrom + "PERSON" + MachineName + " " +
                         beforeWhere + "WHERE " + afterWhere + databaseServices.DMLService.Operators.Equal("1", "1") + " " +
                         beforeGroupBy + "GROUP BY " + afterGroupBy + "NAME " +
                         beforeHaving + "HAVING " + afterHaving + databaseServices.DMLService.Operators.Equal("1", "1") + " " +
                         beforeOrderBy + "ORDER BY " + afterOrderBy + "NAME " +
                         afterStatement;

            sqlExecutor.ExecuteReader(sql, reader => {
                int count = 0;
                while (reader.Read())
                {
                    count++;
                }
                AssertEqual(maxRecordsValue, count, string.Format(ERROR_MESSAGE_FORMAT, "MaxRecords", sql));
            });
        }