public override TestFramework VisitSubgraph([NotNull] DOTParser.SubgraphContext context) { TestUnitInfo info = this.Context.TestUnits.Peek(); TestSuite suite = CreateTestSuite(info, this.Context.ParentSuite); this.Context.ParentSuite = suite; if (this.Context.MasterTestSuite == null) { this.Context.MasterTestSuite = suite; } // Visit Children this.Framework = base.VisitSubgraph(context); // Register any child test cases while (info != this.Context.TestUnits.Peek()) { CreateTestCase(this.Context.TestUnits.Pop(), this.Context.ParentSuite); } this.Context.TestUnits.Pop(); this.Context.ParentSuite = (TestSuite)suite.Parent; return(this.Framework); }
/// <summary> /// Populates the provided TestUnit with the test unit information /// </summary> /// <typeparam name="T">A TestUnit derived type</typeparam> /// <param name="info">The currently accumulated test unit information</param> /// <param name="unit">The test unit instance which is to be populated</param> /// <returns>unit</returns> private static T PopulateTestUnit <T>(TestUnitInfo info, T unit) where T : TestUnit { if ((!string.IsNullOrEmpty(info.id)) && (info.id.Length > 2)) { // Remove the 'tu' prefix from the test unit string ID int id = 0; if (int.TryParse(info.id.Substring(2), NumberStyles.Integer, CultureInfo.InvariantCulture, out id)) { unit.Id = id; } } unit.Source = info.SourceInfo; unit.Labels = info.Labels; unit.DefaultEnabled = info.DefaultEnabled; // Default Enabled // Timeout // Expected Failures // Dependencies return(unit); }
public override TestFramework VisitSubgraph([NotNull] DOTParser.SubgraphContext context) { TestUnitInfo info = this.Context.TestUnits.Peek(); TestSuite suite = CreateTestSuite(info, this.Context.ParentSuite); this.Context.ParentSuite = suite; if (this.Context.MasterTestSuite == null) { this.Context.MasterTestSuite = suite; } // Visit Children this.Framework = base.VisitSubgraph(context); // Register any child test cases while (info != this.Context.TestUnits.Peek()) { TestCase test = CreateTestCase(this.Context.TestUnits.Pop(), this.Context.ParentSuite); Visit(test); } // NOTE Suite is visited after children since it is at this point that we // can guarantee that the suite is fully formed Visit(suite); this.Context.TestUnits.Pop(); this.Context.ParentSuite = (TestSuite)suite.Parent; return(this.Framework); }
public override TestFramework VisitNode_stmt([NotNull] DOTParser.Node_stmtContext context) { TestUnitInfo info = new TestUnitInfo(context.node_id().GetText()); foreach (var attribute in GetKeyValuePairs(context.attr_list())) { switch (attribute.Key) { case "color": { // 'green' implies that the test is explicitly enabled by default // 'yellow' implies that it is enabled, but *may* be disabled info.DefaultEnabled = (attribute.Value == "green"); break; } case "label": { // Parse BOOST Test specific content info.Parse(attribute.Value.Trim('"')); break; } } } ; this.Context.TestUnits.Push(info); return(base.VisitNode_stmt(context)); }
/// <summary> /// Parses test unit information from the provided string /// </summary> /// <param name="value">The string to parse</param> /// <returns>Test unit information contained within value</returns> /// <exception cref="FormatException"></exception> public TestUnitInfo Parse(string value) { TestUnitInfo info = new TestUnitInfo(this.id); string[] properties = value.Split('|'); if (properties.Length > 0) { info.Name = properties[0]; } if (properties.Length > 1) { info.SourceInfo = SourceFileInfo.Parse(properties[1]); } if (properties.Length > 2) { foreach (var attribute in ParseKeyValuePairs(properties.Skip(2))) { ParseNamedAttribute(info, attribute); } } // Replace the contents of 'this' with that of 'info' Set(info); return(this); }
public TestUnitInfo Get_Test_Unit_By_Id(int testUnitId) { TestUnitInfo retVal = new TestUnitInfo(); List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add(new SqlParameter("@Test_Unit_Id", testUnitId)); DataTable dt = _sqlRepo.ExecuteDataTable(sqlParams, StoredProcedures.Get_Test_Unit_By_Id_sp.ToString(), CommandType.StoredProcedure); if (dt != null && dt.Rows.Count > 0) { int count = 0; List <DataRow> drList = new List <DataRow>(); drList = dt.AsEnumerable().ToList(); count = drList.Count(); foreach (DataRow dr in drList) { retVal = (Get_Test_Unit_Values(dr)); } } return(retVal); }
/// <summary> /// Parses a Boost Test DOT named attribute label /// </summary> /// <param name="info">The test unit information structure which to populate</param> /// <param name="attribute">The attribute to parse</param> private static void ParseNamedAttribute(TestUnitInfo info, KeyValuePair <string, string> attribute) { switch (attribute.Key) { case "timeout": { info.Timeout = uint.Parse(attribute.Value, CultureInfo.InvariantCulture); break; } case "expected failures": { info.ExpectedFailures = uint.Parse(attribute.Value, CultureInfo.InvariantCulture); break; } case "labels": { var labels = attribute.Value.Split(new[] { " @" }, StringSplitOptions.RemoveEmptyEntries); if (labels.Length > 0) { info.Labels = labels; } break; } } }
public TestUnitInfo Get_Test_Unit_By_Id(int testUnitId) { TestUnitInfo testUnit = new TestUnitInfo(); TestUnitRepo tRepo = new TestUnitRepo(); testUnit = tRepo.Get_Test_Unit_By_Id(testUnitId); return(testUnit); }
/// <summary> /// Sets the current instance properties to the one provided /// </summary> /// <param name="value"></param> private void Set(TestUnitInfo value) { this.id = value.id; this.Name = value.Name; this.SourceInfo = value.SourceInfo; this.DefaultEnabled = value.DefaultEnabled; this.Timeout = value.Timeout; this.ExpectedFailures = value.ExpectedFailures; this.Labels = value.Labels; this.Parents = value.Parents; this.Dependencies = value.Dependencies; }
public TestUnitViewModel() { Test_Unit = new TestUnitInfo(); Test_Unit_Grid = new List <TestUnitInfo>(); Edit_Mode = new Test_Unit_Edit_Mode(); Filter = new Test_Unit_Filter(); Pager = new PaginationInfo(); Friendly_Message = new List <FriendlyMessageInfo>(); }
public override TestFramework VisitEdge_stmt([NotNull] DOTParser.Edge_stmtContext context) { TestUnitInfo info = this.Context.TestUnits.Peek(); if (info != null) { var lhs = context.node_id(); var rhs = lhs; var edgeRhs = context.edgeRHS(); // NOTE Boost Test DOT output only define one edge per edge statement if (edgeRhs.edgeop().Length == 1) { var edgeop = edgeRhs.edgeop()[0]; // Ensure that a directed edge '->' token is used if (edgeop.GetToken(DOTLexer.T__7, 0) != null) { rhs = edgeRhs.node_id()[0]; } } if ((lhs != rhs) && (rhs != null)) { // Identify whether this edge is a constraining edge (i.e. an actual graph edge) or a non-constraining edge bool constraint = !GetKeyValuePairs(context.attr_list()).Any((attribute) => (attribute.Key == "constraint") && (attribute.Value == "false")); // This implies a test dependency if ((lhs.GetText() == info.id) && !constraint) { info.Dependencies.Add(rhs.GetText()); } // This implies a test unit relationship else if (rhs.GetText() == info.id) { info.Parents.Add(lhs.GetText()); } } } return(base.VisitEdge_stmt(context)); }
private TestUnitInfo Get_Test_Unit_Values(DataRow dr) { TestUnitInfo testUnits = new TestUnitInfo(); testUnits.Test_Unit_Id = Convert.ToInt32(dr["Test_Unit_Id"]); testUnits.Test_Unit_Name = Convert.ToString(dr["Test_Unit_Name"]); testUnits.Status = Convert.ToBoolean(dr["Status"]); testUnits.CreatedBy = Convert.ToInt32(dr["CreatedBy"]); testUnits.CreatedOn = Convert.ToDateTime(dr["CreatedOn"]); testUnits.UpdatedBy = Convert.ToInt32(dr["UpdatedBy"]); testUnits.UpdatedOn = Convert.ToDateTime(dr["UpdatedOn"]); return(testUnits); }
private List <SqlParameter> Set_Values_In_Test_Unit(TestUnitInfo testUnitInfo) { List <SqlParameter> sqlParamList = new List <SqlParameter>(); sqlParamList.Add(new SqlParameter("@Test_Unit_Name", testUnitInfo.Test_Unit_Name)); sqlParamList.Add(new SqlParameter("@Status", testUnitInfo.Status)); sqlParamList.Add(new SqlParameter("@UpdatedBy", testUnitInfo.UpdatedBy)); if (testUnitInfo.Test_Unit_Id == 0) { sqlParamList.Add(new SqlParameter("@CreatedBy", testUnitInfo.CreatedBy)); } if (testUnitInfo.Test_Unit_Id != 0) { sqlParamList.Add(new SqlParameter("@Test_Unit_Id", testUnitInfo.Test_Unit_Id)); } return(sqlParamList); }
public List <TestUnitInfo> GetTestUnit(string testUnitName) { List <TestUnitInfo> retVal = new List <TestUnitInfo>(); try { using (SqlConnection con = new SqlConnection(_sqlCon)) { con.Open(); using (SqlCommand command = new SqlCommand("GetTestUnitAutoComplete_sp", con)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@TestUnitName", testUnitName)); SqlDataReader dataReader = command.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { TestUnitInfo testUnit = new TestUnitInfo(); testUnit.Label = Convert.ToString(dataReader["TestUnitName"]); testUnit.Value = Convert.ToInt32(dataReader["TestUnitId"]); retVal.Add(testUnit); } } dataReader.Close(); } } } catch (Exception ex) { throw ex; } return(retVal); }
public void Update(TestUnitInfo testUnit) { _sqlRepo.ExecuteNonQuery(Set_Values_In_Test_Unit(testUnit), StoredProcedures.Update_Test_Unit_sp.ToString(), CommandType.StoredProcedure); }
/// <summary> /// Creates a TestCase instance from the provided TestUnitInfo structure /// </summary> /// <param name="info">The currently accumulated test unit information</param> /// <param name="parent">The parent test suite of this test unit</param> /// <returns>A TestCase based on the provided information</returns> private static TestCase CreateTestCase(TestUnitInfo info, TestSuite parent) { return(PopulateTestUnit(info, new TestCase(info.Name, parent))); }
public void Update(TestUnitInfo testUnit) { TestUnitRepo tRepo = new TestUnitRepo(); tRepo.Update(testUnit); }
public void Insert(TestUnitInfo testUnit) { TestUnitRepo tRepo = new TestUnitRepo(); tRepo.Insert(testUnit); }