/// <summary> /// Updates the step according to this translation /// </summary> /// <param name="step"></param> public void UpdateStep(Step step) { Step previousStep = step.PreviousStep; foreach (ReqRef reqRef in Requirements) { if (!IsRequirementPresent(step, reqRef)) { step.appendRequirements((ReqRef) reqRef.Duplicate()); } } int subStepCounter = 1; foreach (SubStep subStep in SubSteps) { bool addSubStep = true; if (subStep.ReferencesMessages()) { addSubStep = step.Messages.Count > 0; } if (addSubStep) { SubStep newSubStep = (SubStep) acceptor.getFactory().createSubStep(); newSubStep.setSkipEngine(subStep.getSkipEngine()); newSubStep.Comment = subStep.Comment; newSubStep.Name = subStep.Name; step.appendSubSteps(newSubStep); if (previousStep != null && previousStep.Distance != step.Distance && subStepCounter == 1) { Action newAct = (Action) acceptor.getFactory().createAction(); string distance = step.getDistance(); if (!distance.Contains(".")) { distance = distance + ".0"; } newAct.ExpressionText = "OdometryInterface.UpdateDistance ( " + distance + " )"; newSubStep.setSkipEngine(false); newSubStep.appendActions(newAct); } foreach (Action action in subStep.Actions) { Action newAct = (Action) action.Duplicate(); newSubStep.appendActions(newAct); Review(newAct); } foreach (Expectation expectation in subStep.Expectations) { Expectation newExp = (Expectation) expectation.Duplicate(); newSubStep.appendExpectations(newExp); Review(newExp); } } subStepCounter++; } }
/// <summary> /// Updates an expression according to translation rules /// </summary> /// <param name="step">the step in which the expression occurs</param> /// <param name="expression"></param> /// <returns>the updated string</returns> private string ReviewExpression(Step step, string expression) { string retVal = expression; if (expression.IndexOf('%') >= 0) { SubSequence subSequence = step.TestCase.SubSequence; retVal = retVal.Replace("%D_LRBG", format_decimal_as_str(subSequence.getD_LRBG())); retVal = retVal.Replace("%Level", format_level(subSequence.getLevel())); retVal = retVal.Replace("%Mode", format_mode(subSequence.getMode())); retVal = retVal.Replace("%NID_LRBG", format_decimal_as_str(subSequence.getNID_LRBG())); retVal = retVal.Replace("%Q_DIRLRBG", format_decimal_as_str(subSequence.getQ_DIRLRBG())); retVal = retVal.Replace("%Q_DIRTRAIN", format_decimal_as_str(subSequence.getQ_DIRTRAIN())); retVal = retVal.Replace("%Q_DLRBG", format_decimal_as_str(subSequence.getQ_DLRBG())); retVal = retVal.Replace("%RBC_ID", format_decimal_as_str(subSequence.getRBC_ID())); retVal = retVal.Replace("%RBCPhone", format_str(subSequence.getRBCPhone())); retVal = retVal.Replace("%Step_Distance", step.getDistance() + ""); retVal = retVal.Replace("%Step_LevelIN", format_level(step.getLevelIN())); retVal = retVal.Replace("%Step_LevelOUT", format_level(step.getLevelOUT())); retVal = retVal.Replace("%Step_ModeIN", format_mode(step.getModeOUT())); retVal = retVal.Replace("%Step_ModeOUT", format_mode(step.getModeOUT())); int max_step_messages = 8; for (int i = 0; i < max_step_messages; i++) { if (retVal.IndexOf("%Step_Messages_" + i) >= 0) { if (step.StepMessages.Count > i) { DBMessage message = step.StepMessages[i] as DBMessage; if (message != null) { retVal = retVal.Replace("%Step_Messages_" + i, format_message(message)); } } } } if (retVal.IndexOf("%") > 0) { step.AddError("Cannot completely translate this step"); } } return retVal; }