/** * Re-evaluate a unit test. */ public UnitTestResult Reevaluate(string test_datafile, int utid, bool aggr) { // Create a new variable table for this unit test. UnitTestVariableTable vtable = new UnitTestVariableTable(this.location_); try { // Open the test database. this.test_db_.Open(test_datafile); string test_uuid = this.test_db_.GetTestUUID(); vtable.Open(test_uuid, utid); DbTransaction transaction = vtable.BeginTransaction(); try { // Get the variable table for this unit test. This table is then sent // back to the database for processing, i.e., to execute the user-defined // expression to evaluate the unit test. this.create_variable_table(test_datafile, ref vtable); // Delete rows with incomplete data. vtable.Compact(); // Commit the transaction. transaction.Commit(); return(this.evaluate_i(vtable, aggr)); } catch (Exception) { transaction.Rollback(); throw; } } finally { this.test_db_.Close(); vtable.Close(); } }
/** * Get the data trend for the unit test. */ public UnitTestDataTrend GetDataTrend(string testdata, int utid) { // First, get the SQL string for selecting the data trend. List <string> groups; string sqlstr = this.create_evaluation_query(utid, true, out groups); // Create a new variable table for this unit test. UnitTestVariableTable vtable = new UnitTestVariableTable(this.location_); // Get the UUID for this test. this.test_db_.Open(testdata); string test_uuid = this.test_db_.GetTestUUID(); // Open the variable table. vtable.Open(test_uuid, utid); DbTransaction transaction = vtable.BeginTransaction(); try { // Evalute the unit test. DataTable results = new DataTable(); vtable.Evaluate(sqlstr, ref results); // Commit the transaction. transaction.Commit(); UnitTestDataTrend trend = new UnitTestDataTrend(); if (groups.Count == 0) { // Write the data set for the single group. foreach (DataRow row in results.Rows) { trend.Data.Add(row["result"]); } } else { string current_group = String.Empty; DataTrend group_data = new DataTrend(); foreach (DataRow grprow in results.Rows) { // First, construct the name of the group for this row in // the data table. List <string> name_list = new List <string> (); foreach (string name in groups) { name_list.Add((string)grprow[name]); } string grp_name = String.Join(".", name_list.ToArray()); if (grp_name != current_group) { if (current_group != String.Empty) { // Insert the group data into the collection. trend.GroupData.Add(current_group, group_data); // End the current group's data by creating. group_data = new DataTrend(); } // Save the new group name. current_group = grp_name; } // Insert the value into the group's result. group_data.Add(grprow["result"]); } if (group_data.Count > 0) { trend.GroupData.Add(current_group, group_data); } } return(trend); } catch (Exception) { transaction.Rollback(); throw; } finally { this.test_db_.Close(); vtable.Close(); } }