// FIXME : この処理は本当は DataTableValidator でやるべき private DataRow SelectResultRow(DataTable result, DataRow keyRow, Table tableInfo, Row rowInfo, List <string> keyColumns) { int rowCount = result.Rows.Count; if (rowInfo.Deleted) { if (rowCount == 0) { return(null); } else { Assertie.Fail("M_Fixture_Temp_DatabaseValidator_UnexpectedData", result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow)); } } if (rowCount == 0) { string message = (keyColumns.Count == result.Columns.Count) ? "M_Fixture_Temp_DatabaseValidator_NotFound_With_Comment" : "M_Fixture_Temp_DatabaseValidator_NotFound"; Assertie.Fail(message, result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow)); } if (rowCount > 1) { Assertie.Fail("M_Fixture_Temp_DatabaseValidator_OneMoreData", result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow)); } return(result.Rows[0]); }
public void Validate <TException>(Action action, string typeName) where TException : Exception { bool isNormalEnd = false; try { action(); isNormalEnd = true; } catch (TException e) { Loggi.Debug(e); object obj = e; Delegate editor = GetExceptionEditor(e.GetType()); if (editor != null) { obj = editor.DynamicInvoke(e); } Validate(obj, typeName); } if (isNormalEnd) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_Exception", typeof(TException).Name); } }
protected virtual bool AssertEmpty(Table table, Row row, string columnName, string expected, object actual) { if (Strings.IsEmpty(expected)) { if (actual == null) { return(true); } if (actual is string && Strings.IsEmpty((string)actual)) { return(true); } Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, "", actual, GetType(actual)); } if (NULL.Equals(expected)) { if (actual != null) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, NULL, actual, GetType(actual)); } return(true); } if (EMPTY.Equals(expected)) { if (actual == null || !(actual is string) || ((string)actual).Length > 0) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, EMPTY, ToStringInternal(actual), GetType(actual)); } return(true); } return(false); }
protected virtual void AssertNull(string typeName) { if (Section.HasTable(typeName) && !IsNull(Section.GetTable(typeName))) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertNull", typeName, Section.GetTable(typeName)); } }
private string[] GetTableNamesFrom(DataSet dataSet) { List <string> tableNames = new List <string>(); if (ValidateTableNames(dataSet)) { foreach (DataTable table in dataSet.Tables) { tableNames.Add(table.TableName); } } else if (dataSet.Tables.Count > Section.TableNames.Count) { Assertie.Fail( "M_Fixture_Temp_ObjectValidator_AssertTableNumberImp", Section.TableNames.Count, dataSet.Tables.Count, Section); } else { string messageFormat = Resi.Get("M_Fixture_Temp_ObjectValidator_UseTableOrder"); Loggi.Warn(String.Format(messageFormat, Section)); for (int i = 0; i < dataSet.Tables.Count; i++) { Loggi.Warn("DataSet.Table[" + i + "] = " + Section.TableNames[i]); tableNames.Add(Section.TableNames[i]); } } return(tableNames.ToArray()); }
public override void Validate(object obj, params string[] typeName) { DataSet dataSet = (DataSet)obj; if (typeName == null || typeName.Length == 0) { typeName = GetTableNamesFrom(dataSet); if (dataSet.Tables.Count != Section.TableNames.Count) { Assertie.Fail( "M_Fixture_Temp_ObjectValidator_AssertTableNumberEquals", Section.TableNames.Count, dataSet.Tables.Count, Section); } } if (dataSet.Tables.Count < typeName.Length) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertTableNumberExp", ToStringInternal(typeName), ToStringInternal(dataSet.Tables), Section); } List <DataTable> dataTables = CreateDataTableList(dataSet.Tables); for (int i = 0; i < typeName.Length; i++) { DataTable dataTable = GetDataTable(typeName[i], dataTables); Validate(dataTable, typeName[i]); } }
public override void Validate <TException>(Action action, string typeName) { bool isNormalEnd = false; try { action(); isNormalEnd = true; } catch (TException e) { Loggi.Debug(e); Validate(e, typeName); } if (isNormalEnd) { Assertie.Fail("M_Fixture_Temp_ObjectValidator_Exception", typeof(TException).Name); } }
protected virtual bool AssertNotEmpty(Table table, Row row, string columnName, string expected, object actual) { if ("*".Equals(expected)) { if (actual != null) { if (!(actual is string)) { return(true); } if (!Strings.IsEmpty((string)actual)) { return(true); } } Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, "*", ToStringInternal(actual), GetType(actual)); } return(false); }