/// <summary> /// Translates the current step according to the translation dictionary /// Removes all preconditions, actions and expectations /// </summary> /// <param name="translationDictionary"></param> public void Translate(Translations.TranslationDictionary translationDictionary) { if (getTranslationRequired()) { SubSteps.Clear(); Translations.Translation translation = translationDictionary.findTranslation(getDescription()); if (translation != null) { translation.UpdateStep(this); setTranslated(true); } } }
/// <summary> /// Translates the current step according to the translation dictionary /// Removes all preconditions, actions and expectations /// </summary> /// <param name="applyTranslation">Indicates that the translation should be applied. Otherwise, this method only cleans the step. /// This is used to handle the fact that a blocking error has been found, and translating the sub sequence should be stopped, /// but the next steps should be cleaned</param> /// <returns>False if an error has been found while translating this step, or if translations should not be applied</returns> public bool Translate(bool applyTranslation) { bool retVal = applyTranslation; Counter counter = new Counter(); counter.visit(this); if (counter.Issues[IssueKind.Blocking] != 0) { retVal = false; } if (getTranslationRequired()) { Util.DontNotify(() => { setTranslated(false); SubSteps.Clear(); if (retVal) { Translation translation = EFSSystem.FindTranslation(this); if (translation != null) { translation.UpdateStep(this); setTranslated(true); } else { AddWarning("Cannot find translation for this step"); } } }); } return(retVal); }
public override bool TryParse() { if (!base.TryParse()) { return(false); } // update the duration for the last step TestReport ownerTest = (TestReport)OwnerTest; StepReport lastStep = ownerTest.LastStep; if (lastStep != null) { TimeSpan ts = StartTime - lastStep.StartTime; lastStep.DurationSeconds = (decimal)ts.TotalSeconds; } ownerTest.LastStep = this; // test object path, operation and operation data TestObjectExtType testObj = Node.Data.Extension.TestObject; if (testObj != null) { TestObjectOperation = testObj.Operation; TestObjectOperationData = testObj.OperationData; if (!string.IsNullOrWhiteSpace(TestObjectOperationData) && Node.Status != ReportStatus.Failed) { Name += " " + testObj.OperationData; } TestObjectPathObjects = testObj.Path; if (TestObjectPathObjects != null && TestObjectPathObjects.Count() > 0) { TestObjectPath = string.Empty; foreach (TestObjectPathObjectExtType pathObj in TestObjectPathObjects) { // sample of pathObjStr: Window("Notepad") string pathObjStr = string.Empty; if (!string.IsNullOrWhiteSpace(pathObj.Type)) { pathObjStr = pathObj.Type; } if (!string.IsNullOrWhiteSpace(pathObj.Name)) { if (string.IsNullOrWhiteSpace(pathObjStr)) { pathObjStr = pathObj.Name; } else { pathObjStr += string.Format(" (\"{0}\")", pathObj.Name); } } // sample of TestObjectPath: Window("Notepad").WinMenu("Menu") if (!string.IsNullOrWhiteSpace(pathObjStr)) { if (!string.IsNullOrWhiteSpace(TestObjectPath)) { TestObjectPath += "."; } TestObjectPath += pathObjStr; } } } } // smart identification SmartIdentification = Node.Data.Extension.SmartIdentificationInfo; // contexts and sub-steps SubSteps.Clear(); ReportNodeType[] childNodes = Node.ReportNode; if (childNodes != null) { foreach (ReportNodeType node in childNodes) { // sub-steps StepReport subStep = SubSteps.TryParseAndAdd(node, this.Node); if (subStep != null) { AllStepsEnumerator.Add(subStep); AllStepsEnumerator.Merge(subStep.AllStepsEnumerator); continue; } // contexts ContextReport context = Contexts.TryParseAndAdd(node, this.Node); if (context != null) { AllStepsEnumerator.Merge(context.AllStepsEnumerator); continue; } } } return(true); }