.net - Verifying that a DataTable is sorted -


i working on creating custom database test condition in visual studio, , trying verify sort order.

i have no problem verifying rows in datatable sorted, want verify each sort column has @ least 1 grouping more 1 distinct value.

i maintaining list of integers define sorted columns (negative integers indicate descending sort order - , absolute value of integer column number).

let me clarify.

i writing unit test condition verifies sorted datatable. can verify row in correct sorted order, want verify result set contains data tests sort. in order words, result set 1 row or number of duplicate rows indeed sorted, doesn't test sort.

i need verify each level of sort contains @ least 2 distinct values in @ least 1 grouping.

in past used combination of sql , .net code , used following set of queries make sure there enough data test sort.

select top 1 count(distinct column1)  table  having count(distinct column1) > 1  select top 1 column1, count(distinct column2)  table  group column1  having count(distinct column2) > 1  select top 1 column1, column2, count(distinct column3) table group column1, column2 having count(distinct column3) > 1 

where have query each level , queries must return non-empty result set in order unit test pass.

my real question how duplicate/convert sql code above linq?

i presume verify it's sorted double loop along lines of

for (int = 1; < rowcount; i++) {     (int j = 0; j < sortcolcount; j++) {         int col = colnum(sortcols[j]);         int d = compare(getvalue(rows[i], col), getvalue(rows[i-1], col));         if (d == 0) continue;         // insert here         assert(d == coldir(sortcols[j]));     } }
need i've put comment insert command flag sort column d tested (using e.g. bool array). after loop assert each sort column tested.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -