I am working on creating a custom database validation condition in Visual Studio, and I am trying to verify the sort order.
I have no problem verifying that the rows in the DataTable are actually sorted, but I also want to verify that each sort column has at least one group with more than one distinct value.
I maintain a list of integers that define the sorted columns (negative integers indicate the descending sort order), and the absolute value of the integer is the column number.
Let me clarify.
I am writing a unit test condition that tests a sorted DataTable. I can verify that the row is in the correct sort order, but I want to verify that the result set contains data that actually checks the sort. For words, a result set with only one row or any number of duplicate rows is indeed sorted, but this does not actually verify the sorting.
I need to verify that each sort level contains at least two different values ββin at least one group.
In the past, I used a combination of SQL and .Net code and used the following set of queries to make sure that there was enough data to check the sorting.
SELECT TOP 1 COUNT(DISTINCT column1)
FROM table
HAVING COUNT(DISTINCT column1) > 1
SELECT TOP 1 column1, COUNT(DISTINCT column2)
FROM table
GROUP BY column1
HAVING COUNT(DISTINCT column2) > 1
SELECT TOP 1 column1, column2, COUNT(DISTINCT column3)
FROM table
GROUP BY column1, column2
HAVING COUNT(DISTINCT column3) > 1
Where I have a query for each level, and all queries must return a non-empty result set in order to pass the unit test.
: / SQL LINQ?