private void CalculateHashValues(DataTable dt, Dictionary<Int64, CompareHelper> dict, DataRowKeysComparer keyComparer, bool isSystemUnderTest) { dict.Clear(); Int64 keysHashed; Int64 valuesHashed; foreach (DataRow row in dt.Rows) { CompareHelper hlpr = new CompareHelper(); keyComparer.GetHashCode64_KeysValues(row, out keysHashed, out valuesHashed); hlpr.KeysHashed = keysHashed; hlpr.ValuesHashed = valuesHashed; hlpr.DataRowObj = row; //Check that the rows in the reference are unique // All the rows should be unique regardless of whether it is the system under test or the result set. if (dict.ContainsKey(keysHashed)) { throw new ResultSetComparerException( string.Format("The {0} data set has some duplicated keys. Check your keys definition or the result set defined in your {1}.", isSystemUnderTest ? "actual" : "expected", isSystemUnderTest ? "system-under-test" : "assertion" ) ); } dict.Add(keysHashed, hlpr); } }
private void BuildRowDictionary(DataTable dt, Dictionary<KeyCollection, CompareHelper> dict, DataRowKeysComparer keyComparer, bool isSystemUnderTest) { dict.Clear(); foreach (DataRow row in dt.Rows) { CompareHelper hlpr = new CompareHelper(); var keys = keyComparer.GetKeys(row); hlpr.Keys = keys; hlpr.DataRowObj = row; //Check that the rows in the reference are unique // All the rows should be unique regardless of whether it is the system under test or the result set. if (dict.ContainsKey(keys)) { throw new ResultSetComparerException( string.Format("The {0} data set has some duplicated keys. Check your keys definition or the result set defined in your {1}. The duplicated hashcode is {2}.\r\nRow to insert:{3}.\r\nRow already inserted:{4}.", isSystemUnderTest ? "actual" : "expected", isSystemUnderTest ? "system-under-test" : "assertion", keys.GetHashCode(), RowToString(row), RowToString(dict[keys].DataRowObj) ) ); } dict.Add(keys, hlpr); } }