private void BuildRowDictionary(DataTable dt, Dictionary <KeyCollection, RowHelper> dict, DataRowKeysComparer keyComparer, bool isSystemUnderTest) { dict.Clear(); foreach (DataRow row in dt.Rows) { RowHelper hlpr = new RowHelper(); 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 EquivalerException( 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); } }
private void BuildRowDictionary(DataTable dt, DataRowKeysComparer keyComparer, Dictionary <KeyCollection, int> dict) { dict.Clear(); foreach (DataRow row in dt.Rows) { RowHelper hlpr = new RowHelper(); var keys = keyComparer.GetKeys(row); hlpr.Keys = keys; //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)) { dict[keys]++; } else { dict.Add(keys, 1); } } }
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); } }