public void ShouldEvaluateSingleVariableExpression() { var mapOfVariables = new VariableMap(); mapOfVariables.Put("name", "Cenk"); var result = TemplateEngine.Evaluate("Hello {$name}", mapOfVariables); Assert.AreEqual("Hello Cenk", result); }
public void ShouldEvaluateComplexCase() { var mapOfVariables = new VariableMap(); mapOfVariables.Put("name", "Cenk"); var result = TemplateEngine.Evaluate("Hello ${{$name}}", mapOfVariables); Assert.AreEqual("Hello ${Cenk}", result); }
public void ShouldEvaluateWithMultipleExpressions() { var mapOfVariables = new VariableMap(); mapOfVariables.Put("firstName", "Cenk"); mapOfVariables.Put("lastName", "Civici"); var result = TemplateEngine.Evaluate("Hello {$firstName} {$lastName}", mapOfVariables); Assert.AreEqual("Hello Cenk Civici", result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMessageCorrelationWithTransientVariable() public virtual void testMessageCorrelationWithTransientVariable() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().message("message").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', blob);").endEvent().done(); testRule.deploy(instance); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", false))); // when VariableMap correlationKeys = Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", true)); VariableMap variables = Variables.createVariables().putValueTyped("blob", Variables.stringValue("blob", true)); runtimeService.correlateMessage("message", correlationKeys, variables); // then VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult(); assertNull(variableInstance); HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableName("abc").singleResult(); assertNotNull(historicVariableInstance); assertEquals("blob", historicVariableInstance.Value); }
public virtual void fishedAfterAndFinishedAtParameterWorks() { // given start process and evaluate decision VariableMap variables = Variables.createVariables(); variables.put("input1", null); DateTime now = DateTime.Now; DateTime nowMinus2Seconds = new DateTime(now.Ticks - 2000L); DateTime nowPlus2Seconds = new DateTime(now.Ticks + 2000L); ClockUtil.CurrentTime = nowMinus2Seconds; runtimeService.startProcessInstanceByKey("testProcess", variables); ClockUtil.CurrentTime = now; runtimeService.startProcessInstanceByKey("testProcess", variables); ClockUtil.CurrentTime = nowPlus2Seconds; runtimeService.startProcessInstanceByKey("testProcess", variables); // when IList <HistoricDecisionInstance> decisionInstances = optimizeService.getHistoricDecisionInstances(now, now, 10); // then assertThat(decisionInstances.Count, @is(0)); }
public virtual void testDeserializeTransientJsonValue() { // given BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo").startEvent().exclusiveGateway("gtw").sequenceFlowId("flow1").condition("cond", "${S(" + variableName + ").prop(\"foo\").stringValue() == \"bar\"}").userTask("userTask1").endEvent().moveToLastGateway().sequenceFlowId("flow2").userTask("userTask2").endEvent().done(); deployment(modelInstance); JsonValue jsonValue = jsonValue(jsonString, true).create(); VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue); // when runtimeService.startProcessInstanceByKey("foo", variables); // then IList <VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list(); assertEquals(0, variableInstances.Count); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); assertEquals("userTask1", task.TaskDefinitionKey); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPurgeWithExistingProcessInstance() public virtual void testPurgeWithExistingProcessInstance() { //given process with variable and staying process instance in second user task BpmnModelInstance test = Bpmn.createExecutableProcess(PROCESS_DEF_KEY).startEvent().userTask().userTask().endEvent().done(); engineRule.RepositoryService.createDeployment().addModelInstance(PROCESS_MODEL_NAME, test).deploy(); VariableMap variables = Variables.createVariables(); variables.put("key", "value"); engineRule.RuntimeService.startProcessInstanceByKey(PROCESS_DEF_KEY, variables); Task task = engineRule.TaskService.createTaskQuery().singleResult(); engineRule.TaskService.complete(task.Id); // when purge is executed ManagementServiceImpl managementService = (ManagementServiceImpl)engineRule.ManagementService; managementService.purge(); // then no more data exist assertAndEnsureCleanDbAndCache(engineRule.ProcessEngine, true); }
public virtual void testGetTypedXmlValue() { // given XmlValue xmlValue = xmlValue(xmlString).create(); VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue); string processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).Id; // when XmlValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName); // then SpinXmlElement value = typedValue.Value; assertTrue(value.hasAttr("attrName")); assertEquals("attrValue", value.attr("attrName").value()); assertTrue(value.childElements().Empty); assertTrue(typedValue.Deserialized); assertEquals(XML, typedValue.Type); assertEquals(XML_FORMAT_NAME, typedValue.SerializationDataFormat); assertEquals(xmlString, typedValue.ValueSerialized); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testVariableAccessOnDeleteInCalledProcess() public virtual void testVariableAccessOnDeleteInCalledProcess() { // given VariablesCollectingListener.reset(); BpmnModelInstance callActivityProcess = Bpmn.createExecutableProcess("calling").startEvent().callActivity().camundaIn("foo", "foo").calledElement("called").endEvent().done(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: BpmnModelInstance calledProcess = Bpmn.createExecutableProcess("called").startEvent().userTask().camundaTaskListenerClass([email protected]_Fields.EVENTNAME_DELETE, typeof(VariablesCollectingListener).FullName).endEvent().done(); testRule.deploy(callActivityProcess, calledProcess); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("calling", Variables.createVariables().putValue("foo", "bar")); // when runtimeService.deleteProcessInstance(processInstance.Id, null); // then VariableMap collectedVariables = VariablesCollectingListener.CollectedVariables; assertNotNull(collectedVariables); assertEquals(1, collectedVariables.size()); assertEquals("bar", collectedVariables.get("foo")); }
public virtual void testGetDecisionInstancesWithoutAuthorization() { // given VariableMap variables = Variables.createVariables(); variables.put("input1", null); startProcessInstanceByKey("testProcess", variables); try { // when optimizeService.getHistoricDecisionInstances(new DateTime(0L), null, 10); fail("Exception expected: It should not be possible to retrieve the decision instances"); } catch (AuthorizationException e) { // then string exceptionMessage = e.Message; assertTextPresent(userId, exceptionMessage); assertTextPresent(READ_HISTORY.Name, exceptionMessage); assertTextPresent(DECISION_DEFINITION.resourceName(), exceptionMessage); } }
// DMN /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPurgeDmnProcess() public virtual void testPurgeDmnProcess() { // given dmn process which is not managed by process engine rule engineRule.RepositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.testPurgeDmnProcess.dmn").deploy(); VariableMap variables = Variables.createVariables().putValue("key", "value").putValue("season", "Test"); engineRule.DecisionService.evaluateDecisionByKey("decisionId").variables(variables).evaluate(); // when purge is executed ManagementServiceImpl managementService = (ManagementServiceImpl)engineRule.ManagementService; PurgeReport purge = managementService.purge(); // then database and cache is cleaned assertAndEnsureCleanDbAndCache(engineRule.ProcessEngine, true); // and report contains deleted entities assertFalse(purge.Empty); CachePurgeReport cachePurgeReport = purge.CachePurgeReport; assertEquals(2, cachePurgeReport.getReportValue(CachePurgeReport.DMN_DEF_CACHE).Count); assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.DMN_REQ_DEF_CACHE).Count); DatabasePurgeReport databasePurgeReport = purge.DatabasePurgeReport; assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT")); assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY")); assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_REQ_DEF")); assertEquals(2, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_DEF")); if (processEngineConfiguration.HistoryLevel.Equals(org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_FULL)) { assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DECINST")); assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_IN")); assertEquals(1, (long)databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_OUT")); } }
public virtual void testVariableInstanceQuery() { ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy(); VariableMap variables = Variables.createVariables().putValue("my-variable", "a-value"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables); // variable instance query IList <VariableInstance> result = runtimeService.createVariableInstanceQuery().list(); assertEquals(1, result.Count); VariableInstance variableInstance = result[0]; assertEquals("my-variable", variableInstance.Name); // get variable assertNotNull(runtimeService.getVariable(processInstance.Id, "my-variable")); // get variable local assertNotNull(runtimeService.getVariableLocal(processInstance.Id, "my-variable")); repositoryService.deleteDeployment(deployment.Id, true); }
protected internal virtual ConditionEvaluationBuilder createConditionEvaluationBuilder(EvaluationConditionDto conditionDto) { RuntimeService runtimeService = processEngine.RuntimeService; ObjectMapper objectMapper = ObjectMapper; VariableMap variables = VariableValueDto.toMap(conditionDto.Variables, processEngine, objectMapper); ConditionEvaluationBuilder builder = runtimeService.createConditionEvaluation(); if (variables != null && !variables.Empty) { builder.Variables = variables; } if (!string.ReferenceEquals(conditionDto.BusinessKey, null)) { builder.processInstanceBusinessKey(conditionDto.BusinessKey); } if (!string.ReferenceEquals(conditionDto.ProcessDefinitionId, null)) { builder.processDefinitionId(conditionDto.ProcessDefinitionId); } if (!string.ReferenceEquals(conditionDto.TenantId, null)) { builder.tenantId(conditionDto.TenantId); } else if (conditionDto.WithoutTenantId) { builder.withoutTenantId(); } return(builder); }
public DelegateInvocationAnonymousInnerClass(CallableElementActivityBehavior outerInstance, ActivityExecution execution, VariableMap variables, DelegateVariableMapping varMapping) : base(execution, null) { this.outerInstance = outerInstance; this.execution = execution; this.variables = variables; this.varMapping = varMapping; }
public AbstractInstantiationCmd(string processInstanceId, string ancestorActivityInstanceId) : base(processInstanceId) { this.ancestorActivityInstanceId = ancestorActivityInstanceId; this.variables = new VariableMapImpl(); this.variablesLocal = new VariableMapImpl(); }
public PinocchioArithmeticCircuit(VariableMap variableMap) { this.VariableMap = variableMap; }
public Node Resolve(Node expression) { switch (expression) { case UnaryOperatorNode un: switch (un.NodeType) { case NodeTypes.Plus: return(Node.Plus(Resolve(un.Argument))); case NodeTypes.Minus: return(Node.Minus(Resolve(un.Argument))); case NodeTypes.Not: return(Node.Not(Resolve(un.Argument))); } break; case BinaryOperatorNode bn: var left = Resolve(bn.Left); var right = Resolve(bn.Right); switch (bn.NodeType) { case NodeTypes.Add: return(Node.Add(left, right)); case NodeTypes.Subtract: return(Node.Subtract(left, right)); case NodeTypes.Multiply: return(Node.Multiply(left, right)); case NodeTypes.Divide: return(Node.Divide(left, right)); case NodeTypes.Modulo: return(Node.Modulo(left, right)); case NodeTypes.LessThan: return(Node.LessThan(left, right)); case NodeTypes.GreaterThan: return(Node.GreaterThan(left, right)); case NodeTypes.LessThanOrEqual: return(Node.LessThanOrEqual(left, right)); case NodeTypes.GreaterThanOrEqual: return(Node.GreaterThanOrEqual(left, right)); case NodeTypes.Equals: return(Node.Equals(left, right)); case NodeTypes.NotEquals: return(Node.NotEquals(left, right)); case NodeTypes.And: return(Node.And(left, right)); case NodeTypes.Or: return(Node.Or(left, right)); case NodeTypes.Xor: return(Node.Xor(left, right)); case NodeTypes.Pow: return(Node.Power(left, right)); } break; case TernaryOperatorNode tn: return(Node.Conditional(Resolve(tn.Condition), Resolve(tn.IfTrue), Resolve(tn.IfFalse))); case FunctionNode fn: var args = new Node[fn.Arguments.Count]; for (var i = 0; i < args.Length; i++) { args[i] = Resolve(fn.Arguments[i]); } var funtionUpdated = Node.Function(fn.Name, args); if (FunctionMap != null && FunctionMap.TryGetValue(fn.Name, out var function)) { if (function is StaticResolverFunction staticResolverFunction) { var i = 0; foreach (VariableNode argument in staticResolverFunction.Arguments) { VariableMap[argument.Name] = args[i]; i++; } var functionBodyResolved = Resolve(staticResolverFunction.GetBody()); return(functionBodyResolved); } if (function is DynamicResolverFunction dynamicResolverFunction) { var functionBodyResolved = dynamicResolverFunction.GetBody(args); return(functionBodyResolved); } } return(funtionUpdated); case ConstantNode cn: return(cn); case VariableNode vn: if (VariableMap != null && vn.NodeType == NodeTypes.Variable && VariableMap.TryGetValue(vn.Name, out var mapped)) { return(Resolve(mapped)); } else { var vargs = new VariableFoundEventArgs <VariableNode>(this, vn); OnUnknownVariableFound(vargs); if (vargs.Created) { return(vargs.Result); } else { return(vn); } } } return(expression); }
public bool Update(GridData grid, GridData.Row row, ref int colIndex, int pathIndex, UpdateParam param) { // ColumnCount maybe change in loop for (; colIndex < grid.ColumnCount; ++colIndex) { ColumnTag tag = grid.GetColumn(colIndex).ColumnTag; switch (tag.Tag) { case ColumnTag.ETag.AddVariable: // end of bean. // 删除Define变化时没有同步的数据。 HashSet <string> removed = new HashSet <string>(); foreach (var k in VariableMap.Keys) { if (tag.PathLast.Define.Parent.GetVariable(k) == null) { removed.Add(k); } } foreach (var k in removed) { DeleteVarData(k); } return(false); } ColumnTag.VarInfo varInfo = tag.Path[pathIndex]; if (false == VariableMap.TryGetValue(varInfo.Define.Name, out var varData)) { switch (param.UpdateType) { case EUpdate.Data: break; // will new data case EUpdate.CallAction: case EUpdate.Grid: if (varInfo.Define.Type == VarDefine.EType.List) { if (tag.Tag == ColumnTag.ETag.ListStart) { ++colIndex; } colIndex = GridData.FindColumnListEnd(grid, colIndex); } continue; // data not found. continue load. case EUpdate.DeleteData: return(true); // data not found. nothing need to delete. default: throw new Exception("unknown update type"); } varData = new VarData(this, varInfo.Define.Name); VariableMap.Add(varInfo.Define.Name, varData); } else if (param.UpdateType == EUpdate.CallAction) { param.UpdateAction(grid, colIndex, varInfo, varData); } if (varInfo.Define.Type == VarDefine.EType.List) { if (param.UpdateType == EUpdate.DeleteData) { if (pathIndex + 1 < tag.Path.Count) { if (varInfo.ListIndex < varData.Beans.Count) { Bean bean1 = varData.Beans[varInfo.ListIndex]; if (null != bean1) { bean1.Update(grid, row, ref colIndex, pathIndex + 1, param); } // always return true; } } else { if (ColumnTag.ETag.ListStart != tag.Tag) { throw new Exception("应该仅在Tag为ListStart时移除数据. see FormMain.deleteVariable..."); } DeleteVarData(varInfo.Define.Name); } return(true); } if (ColumnTag.ETag.ListStart == tag.Tag) { continue; // 此时没有进入下一级Bean,就在当前Bean再次判断,因为这里没有ListIndex。 } if (tag.Tag == ColumnTag.ETag.ListEnd) { int curListCount = -varInfo.ListIndex; int add = 0; for (int i = curListCount; i < varData.Beans.Count; ++i) { ColumnTag tagSeed = tag.Copy(ColumnTag.ETag.Normal); tagSeed.PathLast.ListIndex = i; add += tag.PathLast.Define.Reference.BuildGridColumns(grid, colIndex + add, tagSeed, -1); } if (curListCount < varData.Beans.Count) // curListCount 至少为1. { varInfo.ListIndex = -varData.Beans.Count; } if (add > 0) { --colIndex; // 新增加了列,回退一列,继续装载数据。 } continue; } if (varInfo.ListIndex >= varData.Beans.Count) { if (EUpdate.Data == param.UpdateType) { for (int i = varData.Beans.Count; i < varInfo.ListIndex; ++i) { varData.AddBean(new Bean(Document, varInfo.Define.Value)); } Bean create = new Bean(Document, varInfo.Define.Value); varData.AddBean(create); if (create.Update(grid, row, ref colIndex, pathIndex + 1, param)) { return(true); } } // 忽略剩下的没有数据的item直到ListEnd。 colIndex = GridData.FindColumnListEnd(grid, colIndex); continue; } Bean bean = varData.Beans[varInfo.ListIndex]; if (null != bean) { if (bean.Update(grid, row, ref colIndex, pathIndex + 1, param)) { return(true); } continue; } if (EUpdate.Data == param.UpdateType) { Bean create = new Bean(Document, varInfo.Define.Value); varData.SetBeanAt(varInfo.ListIndex, create); if (create.Update(grid, row, ref colIndex, pathIndex + 1, param)) { return(true); } } continue; } if (pathIndex + 1 != tag.Path.Count) { throw new Exception("Remain Path, But Is Not A List"); } switch (param.UpdateType) { case EUpdate.Data: // OnGridCellEndEdit update data varData.Value = row.Cells[colIndex].Value; return(true); case EUpdate.CallAction: // 上面已经做完了。 break; case EUpdate.Grid: row.Cells[colIndex].Value = varData.Value; // upate to grid break; // Update Grid 等到 ColumnTag.ETag.AddVariable 才返回。在这个函数开头。 case EUpdate.DeleteData: DeleteVarData(varInfo.Define.Name); return(true); default: throw new Exception("unkown update type. end."); } } return(true); }
public CallableAnonymousInnerClass2(DelegateFormHandler outerInstance, VariableMap properties, VariableScope variableScope) { this.outerInstance = outerInstance; this.properties = properties; this.variableScope = variableScope; }
public virtual IDictionary <string, VariableValueDto> getVariables(bool deserializeValues) { VariableMap variables = getVariableEntities(deserializeValues); return(VariableValueDto.fromMap(variables)); }
protected internal override void updateVariableEntities(VariableMap modifications, IList <string> deletions) { TaskServiceImpl taskService = (TaskServiceImpl)engine.TaskService; taskService.updateVariablesLocal(resourceId, modifications, deletions); }
public DefaultFormFieldValidatorContext(VariableScope variableScope, string configuration, VariableMap submittedValues, FormFieldHandler formFieldHandler) : base() { this.variableScope = variableScope; this.configuration = configuration; this.submittedValues = submittedValues; this.formFieldHandler = formFieldHandler; }
protected internal virtual void startProcess() { VariableMap variables = Variables.putValue("foo", "bar"); processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables); }
public void ShouldPutAndGetValue() { var map = new VariableMap(); map.Put("ABC", "CDE"); Assert.AreEqual("CDE", map.Get("ABC")); }
public void ShouldThrowException() { var map = new VariableMap(); map.Get("ABC"); }
protected internal abstract void startInstance(ActivityExecution execution, VariableMap variables, string businessKey);
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: public void submitFormVariables(final org.camunda.bpm.engine.variable.VariableMap properties, final org.camunda.bpm.engine.delegate.VariableScope variableScope) public virtual void submitFormVariables(VariableMap properties, VariableScope variableScope) { performContextSwitch(new CallableAnonymousInnerClass2(this, properties, variableScope)); }
protected internal abstract void updateVariableEntities(VariableMap variables, IList <string> deletions);
public virtual void transferVariables(VariableScope sourceScope, CmmnActivityExecution caseExecution) { VariableMap variables = getOutputVariables(sourceScope); caseExecution.Variables = variables; }
public static void reset() { collectedVariables = null; }
protected internal virtual DmnDecisionResult doEvaluateDecision(DecisionDefinition decisionDefinition, VariableMap variables) { try { return(evaluateDecision(decisionDefinition, variables)); } catch (Exception e) { throw new ProcessEngineException("Exception while evaluating decision with key '" + decisionDefinitionKey + "'", e); } }
public virtual void notify(DelegateTask delegateTask) { collectedVariables = delegateTask.VariablesTyped; }
protected internal override void updateVariableEntities(VariableMap variables, IList <string> deletions) { CaseService caseService = engine.CaseService; caseService.withCaseExecution(resourceId).setVariablesLocal(variables).removeVariablesLocal(deletions).execute(); }
public virtual void Dispose() { _vim.MarkMap.Clear(); if (_vimErrorDetector.HasErrors()) { var msg = String.Format("Extension Exception: {0}", _vimErrorDetector.GetErrors().First().Message); // Need to clear before we throw or every subsequent test will fail with the same error _vimErrorDetector.Clear(); throw new Exception(msg); } _vimErrorDetector.Clear(); _vim.VimData.SearchHistory.Reset(); _vim.VimData.CommandHistory.Reset(); _vim.VimData.LastCommand = FSharpOption <StoredCommand> .None; _vim.VimData.LastShellCommand = FSharpOption <string> .None; _vim.VimData.AutoCommands = FSharpList <AutoCommand> .Empty; _vim.VimData.AutoCommandGroups = FSharpList <AutoCommandGroup> .Empty; _vim.KeyMap.ClearAll(); _vim.KeyMap.IsZeroMappingEnabled = true; _vim.CloseAllVimBuffers(); _vim.IsDisabled = false; // The majority of tests run without a VimRc file but a few do customize it for specific // test reasons. Make sure it's consistent VimRcState = VimRcState.None; // Reset all of the global settings back to their default values. Adds quite // a bit of sanity to the test bed foreach (var setting in _vim.GlobalSettings.AllSettings) { if (!setting.IsValueDefault && !setting.IsValueCalculated) { _vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue); } } // Reset all of the register values to empty foreach (var name in _vim.RegisterMap.RegisterNames) { _vim.RegisterMap.GetRegister(name).UpdateValue(""); } // Don't let recording persist across tests if (_vim.MacroRecorder.IsRecording) { _vim.MacroRecorder.StopRecording(); } var vimHost = Vim.VimHost as MockVimHost; if (vimHost != null) { vimHost.ShouldCreateVimBufferImpl = false; vimHost.Clear(); } VariableMap.Clear(); }
private void ResetState() { Vim.MarkMap.Clear(); Vim.VimData.SearchHistory.Reset(); Vim.VimData.CommandHistory.Reset(); Vim.VimData.LastCommand = FSharpOption <StoredCommand> .None; Vim.VimData.LastCommandLine = ""; Vim.VimData.LastShellCommand = FSharpOption <string> .None; Vim.VimData.LastTextInsert = FSharpOption <string> .None; Vim.VimData.AutoCommands = FSharpList <AutoCommand> .Empty; Vim.VimData.AutoCommandGroups = FSharpList <AutoCommandGroup> .Empty; Vim.KeyMap.ClearAll(); Vim.DigraphMap.Clear(); Vim.KeyMap.IsZeroMappingEnabled = true; Vim.CloseAllVimBuffers(); Vim.IsDisabled = false; // If digraphs were loaded, reload them. if (Vim.AutoLoadDigraphs) { DigraphUtil.AddToMap(Vim.DigraphMap, DigraphUtil.DefaultDigraphs); } // The majority of tests run without a VimRc file but a few do customize it for specific // test reasons. Make sure it's consistent VimRcState = VimRcState.None; // Reset all of the global settings back to their default values. Adds quite // a bit of sanity to the test bed foreach (var setting in Vim.GlobalSettings.Settings) { if (!setting.IsValueDefault && !setting.IsValueCalculated) { Vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue); } } // Reset all of the register values to empty foreach (var name in Vim.RegisterMap.RegisterNames) { Vim.RegisterMap.GetRegister(name).UpdateValue(""); } // Don't let recording persist across tests if (Vim.MacroRecorder.IsRecording) { Vim.MacroRecorder.StopRecording(); } if (Vim.VimHost is MockVimHost vimHost) { vimHost.ShouldCreateVimBufferImpl = false; vimHost.Clear(); } VariableMap.Clear(); VimErrorDetector.Clear(); TestableSynchronizationContext?.Dispose(); TestableSynchronizationContext = null; }
public void ShouldGiveErrorIfVariableDoesNotExistInTheMap() { var mapOfVariables = new VariableMap(); var result = TemplateEngine.Evaluate("Hello {$name}", mapOfVariables); }