/// <summary> /// Checks to ensure that the dataset is not null, has the specified number of tables /// and whether or not each table MUST have rows in it. /// </summary> /// <param name="requiredNumberOfTables"> /// The number of tables that dataset must contain /// </param> /// <param name="tableMustHaveRowsFlags"> /// A list of boolean flags denoting whether each table in the set MUST have some rows in it. /// e.g. /// /// DataSet ds = GetSomeDataSet(); /// ds.IsPopulated(3, true, false, true); /// /// means that the dataset MUST have 3 tables. The first and third tables MUST have rows in them, /// the second table may or may not have rows in it. /// </param> /// <returns> /// True if the the tables required to be populated actually are, otherwise false. /// </returns> public static bool IsPopulated(this DataSet ds, int requiredNumberOfTables, params bool[] tableMustHaveRowsFlags) { _logger.DebugMethodCalled(ds, requiredNumberOfTables, tableMustHaveRowsFlags); #region Input validation Insist.IsAtLeast(requiredNumberOfTables, 1, "requiredNumberOfTables"); Insist.IsNotNull(tableMustHaveRowsFlags, "tableMustHaveRowsFlags"); Insist.Equality(tableMustHaveRowsFlags.Length, requiredNumberOfTables, "tableMustHaveRowsFlags", "The number of tableMustHaveRowsFlags must match the number of tables"); #endregion if (ds == null || ds.Tables == null || ds.Tables.Count != requiredNumberOfTables) { return(false); } else { for (int i = 0; i < requiredNumberOfTables; i++) { if (tableMustHaveRowsFlags[i] == true && ( ds.Tables[i].Rows == null || ds.Tables[i].Rows.Count == 0 )) { return(false); } } return(true); } }
public void Equality_Thrown_Exception_Has_Correct_Argument_Name() { try { Insist.Equality("ABC123", "DEF456", ARGUMENT_NAME); } catch (ArgumentException e) { Assert.AreEqual(ARGUMENT_NAME, e.ParamName); } }
public void Equality_Thrown_Exception_Has_Correct_Message() { try { Insist.Equality("ABC123", "DEF456", ARGUMENT_NAME, MESSAGE); } catch (ArgumentException e) { Assert.IsTrue(e.Message.Contains(MESSAGE)); } }
public void Equality_Matching_Values_Does_Not_Throw_Exception(Object expected) { Insist.Equality(expected, expected, ARGUMENT_NAME); }
public void Equality_Non_Matching_Values_Throws_Exception() { Insist.Equality("ABC123", "DEF456", ARGUMENT_NAME); }