public void EvaluateConfig(IEngineEnvironmentSettings environmentSettings, IVariableCollection vars, IMacroConfig config, IParameterSet parameters, ParameterSetter setter) { ProcessValueFormMacroConfig realConfig = config as ProcessValueFormMacroConfig; if (realConfig == null) { throw new InvalidCastException("Couldn't cast the rawConfig as a ProcessValueFormMacroConfig"); } string value; if (!vars.TryGetValue(realConfig.SourceVariable, out object working)) { if (parameters.TryGetRuntimeValue(environmentSettings, realConfig.SourceVariable, out object resolvedValue, true)) { value = resolvedValue.ToString(); } else { value = string.Empty; } }
public void UnknownFormNameOnParameterSymbolDoesNotThrow() { string templateJson = @" { ""name"": ""TestTemplate"", ""identity"": ""TestTemplate"", ""symbols"": { ""mySymbol"": { ""type"": ""parameter"", ""replaces"": ""whatever"", ""forms"": { ""global"": [ ""fakeName"" ], } } } } "; JObject configObj = JObject.Parse(templateJson); SimpleConfigModel configModel = SimpleConfigModel.FromJObject(EngineEnvironmentSettings, configObj); IGlobalRunConfig runConfig = null; try { runConfig = ((IRunnableProjectConfig)configModel).OperationConfig; } catch { Assert.True(false, "Should not throw on unknown value form name"); } Assert.NotNull(runConfig); Assert.Equal(1, runConfig.Macros.Count(m => m.VariableName.StartsWith("mySymbol"))); var mySymbolMacro = runConfig.Macros.Single(m => m.VariableName.StartsWith("mySymbol")); Assert.True(mySymbolMacro is ProcessValueFormMacroConfig); ProcessValueFormMacroConfig identityFormConfig = mySymbolMacro as ProcessValueFormMacroConfig; Assert.Equal("identity", identityFormConfig.FormName); }