private bool HasMoreVisibleSubSteps(SubStep aSubStep, ClassEnum aClassEnum) { if (aSubStep.NextSubSteps.Any(ss => ss.HasClass(aClassEnum))) { return(true); } foreach (var subStep in aSubStep.NextSubSteps) { return(HasMoreVisibleSubSteps(subStep, aClassEnum)); } return(false); }
internal void SetSubStep(SubStep aSubStep) { SubStep = aSubStep; _subStepView.StepTextBox.SetText(aSubStep.StepDirectory, aSubStep.StepOrder, aSubStep.StepText, aSubStep.Legend); _subStepView.StepTextBox.QuestLogButtonClicked += () => { MainViewModel.Instance.ShowQuestLog(QuestLog); }; SubStep.IsDoneChanged += (isDone) => { SetIsDone(isDone, false); }; }
/// <summary> /// Indicates whether the corresponding step has been activated /// </summary> /// <param name="subStep"></param> /// <returns></returns> public bool ContainsSubStep(SubStep subStep) { bool retVal = false; if (subStep != null) { if (SubStepActivationCache.ContainsKey(subStep)) { retVal = SubStepActivationCache[subStep] != null; } } return(retVal); }
/// <summary> /// Gives the time of activation of a sub-step /// </summary> /// <param name="subStep"></param> /// <returns>True if the provided rule has been activated</returns> public double GetSubStepActivationTime(SubStep subStep) { double retVal = -1; if (SubStepActivationCache.ContainsKey(subStep)) { SubStepActivated subStepActivated = SubStepActivationCache[subStep]; if (subStepActivated != null) { retVal = subStepActivated.Time; } } return(retVal); }
public int FindNextSubStep(uint Quest, uint StepId) { //Find the highest stepindex int stepindex = -1; for (int i = 0; i < Substeps.Count; i++) { SubStep step = Substeps[i]; if (step.Quest == Quest && step.StepId == StepId) { stepindex = (int)step.SubStepId; } } //Gets the next stepindex; return(stepindex + 1); }
/// <summary> /// Setups the sub-step by applying its actions and adding its expects in the expect list /// </summary> public void SetupSubStep(SubStep subStep) { try { DataDictionary.Generated.ControllersManager.NamableController.DesactivateNotification(); LogInstance = subStep; // No setup can occur when some expectations are still active if (ActiveBlockingExpectations().Count == 0) { EventTimeLine.AddModelEvent(new SubStepActivated(subStep)); } } finally { DataDictionary.Generated.ControllersManager.NamableController.ActivateNotification(); } }
/// <summary> /// Provides the current test step /// </summary> /// <returns></returns> public SubStep CurrentSubStep() { SubStep retVal = null; if (currentSubStepIndex != NO_MORE_STEP) { if (currentSubStepIndex == REBUILD_CURRENT_SUB_STEP) { currentTestCaseIndex = -1; currentStepIndex = -1; currentSubStepIndex = -1; int previousTestCaseIndex = currentTestCaseIndex; int previousStepIndex = currentStepIndex; int previousSubStepIndex = currentSubStepIndex; NextSubStep(); retVal = CurrentSubStep(); while (retVal != null && EventTimeLine.SubStepActivationCache.ContainsKey(retVal)) { previousTestCaseIndex = currentTestCaseIndex; previousStepIndex = currentStepIndex; previousSubStepIndex = currentSubStepIndex; NextSubStep(); retVal = CurrentSubStep(); } currentTestCaseIndex = previousTestCaseIndex; currentStepIndex = previousStepIndex; currentSubStepIndex = previousSubStepIndex; } Step step = CurrentStep(); if (step != null) { if (currentSubStepIndex >= 0 && currentSubStepIndex < step.SubSteps.Count) { retVal = (SubStep)step.SubSteps[currentSubStepIndex]; } } } return(retVal); }
/// <summary> /// Creates a default element /// </summary> /// <param name="enclosingCollection"></param> /// <param name="sourceText"></param> /// <returns></returns> public static Translation CreateDefault(ICollection enclosingCollection, SourceText sourceText) { Translation retVal = (Translation)acceptor.getFactory().createTranslation(); Util.DontNotify(() => { if (sourceText != null) { retVal.Name = sourceText.Name; retVal.appendSourceTexts(sourceText); } else { retVal.Name = "Translation" + GetElementNumber(enclosingCollection); } retVal.appendSubSteps(SubStep.CreateDefault(retVal.SubSteps)); }); return(retVal); }
/// <summary> /// Setups the sub-step by applying its actions and adding its expects in the expect list /// </summary> /// <returns>True if the substep was not already seetup</returns> public bool SetupSubStep(SubStep subStep) { bool retVal = false; if (subStep != null) { if (!EventTimeLine.ContainsSubStep(subStep)) { Util.DontNotify(() => { LogInstance = subStep; CacheImpact = new CacheImpact(); EventTimeLine.AddModelEvent(new SubStepActivated(subStep, CurrentPriority), true); ClearCaches(); }); retVal = true; } } return(retVal); }
public void TestMoveBugReport568() { Dictionary test = CreateDictionary("Test"); NameSpace namespace1 = CreateNameSpace(test, "Kernel"); NameSpace nameSpace2 = CreateNameSpace(namespace1, "MA"); Function function1 = CreateFunction(nameSpace2, "SpeedRestriction", "Boolean"); NameSpace nameSpace3 = CreateNameSpace(namespace1, "MRSP"); Function function2 = CreateFunction(nameSpace3, "SpeedRestriction", "Boolean"); Frame frame = CreateTestFrame(test, "frame"); SubSequence subSequence = CreateSubSequence(frame, "subsequence"); TestCase testCase = CreateTestCase(subSequence, "TestCase"); Step step = CreateStep(testCase, "Step"); SubStep subStep = CreateSubStep(step, "SubStep"); Expectation expectation = CreateExpectation(subStep, "Kernel.MA.SpeedRestriction()"); Expectation expectation2 = CreateExpectation(subStep, "MIN(Kernel.MA.SpeedRestriction, Kernel.MRSP.SpeedRestriction)"); Refactor(function1, "SpeedRestriction"); Assert.AreEqual("Kernel.MA.SpeedRestriction()", expectation.ExpressionText); Assert.AreEqual("MIN(Kernel.MA.SpeedRestriction, Kernel.MRSP.SpeedRestriction)", expectation2.ExpressionText); }
/// <inheritdoc/> public SelfTestStepResult RunStep() { var contextMenu = Service <ContextMenu> .Get(); var dataMgr = Service <DataManager> .Get(); ImGui.Text(this.currentSubStep.ToString()); switch (this.currentSubStep) { case SubStep.Start: contextMenu.ContextMenuOpened += this.ContextMenuOnContextMenuOpened; this.currentSubStep++; break; case SubStep.TestItem: if (this.clickedItemId != 0) { var item = dataMgr.GetExcelSheet <Item>() !.GetRow(this.clickedItemId); ImGui.Text($"Did you click \"{item!.Name.RawString}\", hq:{this.clickedItemHq}, count:{this.clickedItemCount}?"); if (ImGui.Button("Yes")) { this.currentSubStep++; } ImGui.SameLine(); if (ImGui.Button("No")) { return(SelfTestStepResult.Fail); } } else { ImGui.Text("Right-click an item."); if (ImGui.Button("Skip")) { this.currentSubStep++; } } break; case SubStep.TestGameObject: if (!this.clickedPlayerName.IsNullOrEmpty()) { ImGui.Text($"Did you click \"{this.clickedPlayerName}\", world:{this.clickedPlayerWorld}, cid:{this.clickedPlayerCid}, id:{this.clickedPlayerId}?"); if (ImGui.Button("Yes")) { this.currentSubStep++; } ImGui.SameLine(); if (ImGui.Button("No")) { return(SelfTestStepResult.Fail); } } else { ImGui.Text("Right-click a character."); if (ImGui.Button("Skip")) { this.currentSubStep++; } } break; case SubStep.TestSubMenu: if (this.multipleTriggerOne && this.multipleTriggerTwo) { this.currentSubStep++; this.multipleTriggerOne = this.multipleTriggerTwo = false; } else { ImGui.Text("Right-click a character and select both options in the submenu."); if (ImGui.Button("Skip")) { this.currentSubStep++; } } break; case SubStep.TestMultiple: if (this.multipleTriggerOne && this.multipleTriggerTwo) { this.currentSubStep = SubStep.Finish; return(SelfTestStepResult.Pass); } ImGui.Text("Select both options on any context menu."); if (ImGui.Button("Skip")) { this.currentSubStep++; } break; default: throw new ArgumentOutOfRangeException(); } return(SelfTestStepResult.Waiting); }
/// <summary> /// Gives the time of activation of a sub-step /// </summary> /// <param name="subStep"></param> /// <returns>True if the provided rule has been activated</returns> public double GetSubStepActivationTime(SubStep subStep) { double retVal = -1; if (SubStepActivationCache.ContainsKey(subStep)) { SubStepActivated subStepActivated = SubStepActivationCache[subStep]; if (subStepActivated != null) { retVal = subStepActivated.Time; } } return retVal; }
public override void visit(SubStep obj, bool visitSubNodes) { obj.setSkipEngine(false); base.visit(obj, visitSubNodes); }
/// <summary> /// Indicates whether the corresponding step has been activated /// </summary> /// <param name="subStep"></param> /// <returns></returns> public bool ContainsSubStep(SubStep subStep) { bool retVal = false; if (SubStepActivationCache.ContainsKey(subStep)) { retVal = SubStepActivationCache[subStep] != null; } return retVal; }
/// <summary> /// Gives the time of activation of a sub-step /// </summary> /// <param name="rule"></param> /// <param name="time"></param> /// <returns>True if the provided rule has been activated</returns> public double GetNextSubStepActivationTime(SubStep aSubStep) { double retVal = -1; bool stepFound = false; foreach (ModelEvent modelEvent in Events) { if (modelEvent is SubStepActivated) { SubStepActivated subStepActivated = modelEvent as SubStepActivated; if (stepFound) { retVal = subStepActivated.Time; break; } else { if (subStepActivated.SubStep == aSubStep) { stepFound = true; } } } } if (retVal == -1) { retVal = CurrentTime; } return retVal; }
public MainStep GetStepByObj(MainStep ms) { // below are hardcoded instructions for demonstration only, all the instructions should be retrieved from a database if (ms.TaskID == "c1-1" && ms.StepNum == 1) { ms.Instrn = "Write down the current time on a piece of paper according to the wall clock in the room."; ms.TotalSubSteps = 3; ms.SubSteps = new List<SubStep>(); SubStep ss; for (int i = 0; i < ms.TotalSubSteps; i++) { ss = new SubStep(); ss.SubStepNum = i; switch (ss.SubStepNum + 1) { case 1: ss.Instrn = "Get a piece of paper and a pen from the table."; break; case 2: ss.Instrn = "Read the time from the wall clock in the room."; break; case 3: ss.Instrn = "Write down the time on the piece of paper."; break; default: ss.Instrn = "None"; break; } ms.SubSteps.Add(ss); } } else if (ms.TaskID == "c1-1" && ms.StepNum == 2) { ms.Instrn = "Find the meaning of the word \"Computer\" in the dictionary on the table, then write it down on the same piece of paper below the time."; ms.TotalSubSteps = 3; ms.SubSteps = new List<SubStep>(); SubStep ss; for (int i = 0; i < ms.TotalSubSteps; i++) { ss = new SubStep(); ss.SubStepNum = i; switch (ss.SubStepNum + 1) { case 1: ss.Instrn = "Use the dictionary on the table."; break; case 2: ss.Instrn = "Open the dictionary and look for the meaning of the search word."; break; case 3: ss.Instrn = "Write down the meaning of the search word on the paper below the time."; break; default: ss.Instrn = "None"; break; } ms.SubSteps.Add(ss); } } else if (ms.TaskID == "c1-1" && ms.StepNum == 3) { ms.Instrn = "Write down the current time, then put the pen and paper on top of the dictionary neatly."; ms.TotalSubSteps = 3; ms.SubSteps = new List<SubStep>(); SubStep ss; for (int i = 0; i < ms.TotalSubSteps; i++) { ss = new SubStep(); ss.SubStepNum = i; switch (ss.SubStepNum + 1) { case 1: ss.Instrn = "Place the dictionary on the left side of the table."; break; case 2: ss.Instrn = "Write down the time on the same piece of paper."; break; case 3: ss.Instrn = "Put the piece of paper and pen on top of the dictionary."; break; default: ss.Instrn = "None"; break; } ms.SubSteps.Add(ss); } } return ms; }
/// <summary> /// Constructor /// </summary> /// <param name="subStep">The activated step</param> /// <param name="priority"></param> public SubStepActivated(SubStep subStep, acceptor.RulePriority?priority) : base(subStep.Name, subStep, priority) { SubStep = subStep; }
/// <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++; } }
/// <inheritdoc/> public void CleanUp() { this.currentSubStep = SubStep.PrintNormalItem; }
/// <summary> /// Constructor /// </summary> /// <param name="subStep"></param> /// <param name="time"></param> public DelayedSubStep(SubStep subStep, long time) { SubStep = subStep; Time = time; }
/// <summary> /// Activates the rules in the dictionary until stabilisation /// </summary> public void Cycle() { try { DataDictionary.Generated.ControllersManager.NamableController.DesactivateNotification(); LastActivationTime = Time; Utils.ModelElement.ErrorCount = 0; foreach (Generated.acceptor.RulePriority priority in PRIORITIES_ORDER) { // Clears the cache of functions FunctionCacheCleaner.ClearCaches(); // Activates the processing engine HashSet <Activation> activations = new HashSet <Activation>(); foreach (DataDictionary.Dictionary dictionary in EFSSystem.Dictionaries) { foreach (DataDictionary.Types.NameSpace nameSpace in dictionary.NameSpaces) { SetupNameSpaceActivations(priority, activations, nameSpace); } } ApplyActivations(activations); } // Clears the cache of functions FunctionCacheCleaner.ClearCaches(); if (Utils.ModelElement.ErrorCount > 0) { SubStep subStep = CurrentSubStep(); if (subStep != null) { subStep.AddError("Errors were raised while evaluating this sub step. See model view for more informations"); } else { Step step = CurrentStep(); if (step != null) { step.AddError("Errors were raised while evaluating this step. See model view for more informations"); } else { TestCase testCase = CurrentTestCase(); if (testCase != null) { testCase.AddError("Errors were raised while evaluating this test case. See model view for more informations"); } else { SubSequence.AddError("Errors were raised while evaluating this sub sequence. See model view for more informations"); } } } } } finally { DataDictionary.Generated.ControllersManager.NamableController.ActivateNotification(); } EventTimeLine.CurrentTime += Step; }