コード例 #1
0
        public void TestRandomDeferredConfig(int low, int?high)
        {
            string variableName = "myRnd";
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("low", low);
            if (high.HasValue)
            {
                jsonParameters.Add("high", high);
            }

            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("RandomMacro", variableName, jsonParameters);
            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            RandomMacro macro = new RandomMacro();

            macro.EvaluateDeferredConfig(EngineEnvironmentSettings, variables, deferredConfig, parameters, setter);
            ITemplateParameter valueParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out valueParam));
            long randomValue = (long)parameters.ResolvedValues[valueParam];

            Assert.True(randomValue >= low);

            if (high.HasValue)
            {
                Assert.True(randomValue <= high);
            }
        }
コード例 #2
0
        public void EvaluateNowDeferredConfig()
        {
            string variableName = "nowString";
            string format       = "";
            bool   utc          = false;
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("format", format);
            jsonParameters.Add("utc", utc);
            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("NowMacro", variableName, jsonParameters);


            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            NowMacro     macro      = new NowMacro();
            IMacroConfig realConfig = macro.CreateConfig(EngineEnvironmentSettings, deferredConfig);

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, realConfig, parameters, setter);
            ITemplateParameter resultParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out resultParam));
            string   macroNowString = (string)parameters.ResolvedValues[resultParam];
            DateTime macroNowTime   = Convert.ToDateTime(macroNowString);

            TimeSpan difference = macroNowTime.Subtract(DateTime.Now);

            // 10 seconds is quite a lot of wiggle room, but should be fine, and safe.
            Assert.True(difference.TotalSeconds < 10);
        }
コード例 #3
0
        public void TestRandomConfig(int low, int?high)
        {
            string            variableName = "myRnd";
            RandomMacroConfig macroConfig  = new RandomMacroConfig(variableName, low, high);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            RandomMacro macro = new RandomMacro();

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, macroConfig, parameters, setter);

            ITemplateParameter valueParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out valueParam));
            long randomValue = (long)parameters.ResolvedValues[valueParam];

            Assert.True(randomValue >= low);

            if (high.HasValue)
            {
                Assert.True(randomValue <= high);
            }
        }
コード例 #4
0
        public void TestSwitchConfig()
        {
            string variableName  = "mySwitchVar";
            string evaluator     = "C++";
            string dataType      = "string";
            string expectedValue = "this one";
            IList <KeyValuePair <string, string> > switches = new List <KeyValuePair <string, string> >();

            switches.Add(new KeyValuePair <string, string>("(3 > 10)", "three greater than ten - false"));
            switches.Add(new KeyValuePair <string, string>("(false)", "false value"));
            switches.Add(new KeyValuePair <string, string>("(10 > 0)", expectedValue));
            switches.Add(new KeyValuePair <string, string>("(5 > 4)", "not this one"));
            SwitchMacroConfig macroConfig = new SwitchMacroConfig(variableName, evaluator, dataType, switches);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            SwitchMacro macro = new SwitchMacro();

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfig, parameters, setter);
            ITemplateParameter resultParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out resultParam));
            string resultValue = (string)parameters.ResolvedValues[resultParam];

            Assert.Equal(resultValue, expectedValue);
        }
コード例 #5
0
        public void EvaluateNowConfig()
        {
            string         variableName = "nowString";
            string         format       = "";
            bool           utc          = true;
            NowMacroConfig macroConfig  = new NowMacroConfig(variableName, format, utc);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            NowMacro macro = new NowMacro();

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, macroConfig, parameters, setter);
            ITemplateParameter resultParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out resultParam));
            string   macroNowString = (string)parameters.ResolvedValues[resultParam];
            DateTime macroNowTime   = Convert.ToDateTime(macroNowString);

            TimeSpan difference = macroNowTime.Subtract(DateTime.UtcNow);

            // 10 seconds is quite a lot of wiggle room, but should be fine, and safe.
            Assert.True(difference.TotalSeconds < 10);
        }
コード例 #6
0
ファイル: GuidMacroTests.cs プロジェクト: dotnet/templating
        public void TestDefaultFormatIsCaseSensetive()
        {
            string       paramNameLower   = "TestGuidLower";
            IMacroConfig macroConfigLower = new GuidMacroConfig(paramNameLower, "string", string.Empty, "n");
            string       paramNameUpper   = "TestGuidUPPER";
            IMacroConfig macroConfigUpper = new GuidMacroConfig(paramNameUpper, "string", string.Empty, "N");

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            GuidMacro guidMacro = new GuidMacro();

            guidMacro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfigLower, parameters, setter);
            guidMacro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfigUpper, parameters, setter);

            Assert.True(parameters.TryGetParameterDefinition(paramNameLower, out var setParamLower));
            Assert.All(((string)parameters.ResolvedValues[setParamLower]).ToCharArray(), (c) =>
            {
                Assert.True(char.IsLower(c) || char.IsDigit(c));
            });

            Assert.True(parameters.TryGetParameterDefinition(paramNameUpper, out var setParamUpper));
            Assert.All(((string)parameters.ResolvedValues[setParamUpper]).ToCharArray(), (c) =>
            {
                Assert.True(char.IsUpper(c) || char.IsDigit(c));
            });
        }
コード例 #7
0
        public void TestRegexMatchMacroFalse()
        {
            const string          variableName   = "isMatch";
            const string          sourceVariable = "originalValue";
            RegexMatchMacroConfig macroConfig    = new RegexMatchMacroConfig(variableName, null, sourceVariable, @"(((?<=\.)|^)(?=\d)|[^\w\.])");

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new RunnableProjectGenerator.ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            const string sourceValue   = "A1234test";
            const bool   expectedValue = false;

            Parameter sourceParam = new Parameter
            {
                IsVariable = true,
                Name       = sourceVariable
            };

            variables[sourceVariable] = sourceValue;
            setter(sourceParam, sourceValue);

            RegexMatchMacro macro = new RegexMatchMacro();

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfig, parameters, setter);

            Assert.True(parameters.TryGetParameterDefinition(variableName, out ITemplateParameter newParam));
            bool newValue = (bool)parameters.ResolvedValues[newParam];

            Assert.Equal(newValue, expectedValue);
        }
コード例 #8
0
        public void TestDeferredCaseChangeConfig()
        {
            string variableName = "myString";

            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();
            string sourceVariable = "sourceString";

            jsonParameters.Add("source", sourceVariable);
            jsonParameters.Add("toLower", false);
            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("CaseChangeMacro", variableName, jsonParameters);

            CaseChangeMacro        macro      = new CaseChangeMacro();
            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            string    sourceValue = "Original Value SomethingCamelCase";
            Parameter sourceParam = new Parameter
            {
                IsVariable = true,
                Name       = sourceVariable
            };

            variables[sourceVariable] = sourceValue;
            setter(sourceParam, sourceValue);

            macro.EvaluateDeferredConfig(EngineEnvironmentSettings, variables, deferredConfig, parameters, setter);
            ITemplateParameter convertedParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out convertedParam));
            string convertedValue = (string)parameters.ResolvedValues[convertedParam];

            Assert.Equal(convertedValue, sourceValue.ToUpper());
        }
コード例 #9
0
        public void TestCaseChangeToUpperConfig()
        {
            string variableName   = "myString";
            string sourceVariable = "sourceString";
            bool   toLower        = false;

            CaseChangeMacroConfig macroConfig = new CaseChangeMacroConfig(variableName, null, sourceVariable, toLower);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            string    sourceValue = "Original Value SomethingCamelCase";
            Parameter sourceParam = new Parameter
            {
                IsVariable = true,
                Name       = sourceVariable
            };

            variables[sourceVariable] = sourceValue;
            setter(sourceParam, sourceValue);

            CaseChangeMacro macro = new CaseChangeMacro();

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfig, parameters, setter);

            ITemplateParameter convertedParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out convertedParam));
            string convertedValue = (string)parameters.ResolvedValues[convertedParam];

            Assert.Equal(convertedValue, sourceValue.ToUpper());
        }
コード例 #10
0
        public void TestConstantDeferredConfig()
        {
            string variableName = "myConstant";
            string value        = "1048576";
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("value", value);
            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("ConstantMacro", null, variableName, jsonParameters);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            ConstantMacro macro      = new ConstantMacro();
            IMacroConfig  realConfig = macro.CreateConfig(_engineEnvironmentSettings, deferredConfig);

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, realConfig, parameters, setter);
            ITemplateParameter constParameter;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out constParameter));
            string constParamValue = (parameters.ResolvedValues[constParameter]).ToString();

            Assert.Equal(constParamValue, value);
        }
コード例 #11
0
        public void TestSwitchDeferredConfig()
        {
            string variableName  = "mySwitchVar";
            string evaluator     = "C++";
            string dataType      = "string";
            string expectedValue = "this one";
            string switchCases   = @"[
                {
                    'condition': '(3 > 10)',
                    'value': 'three greater than ten'
                },
                {
                    'condition': '(false)',
                    'value': 'false value'
                },
                {
                    'condition': '(10 > 0)',
                    'value': '" + expectedValue + @"'
                },
                {
                    'condition': '(5 > 4)',
                    'value': 'not this one'
                }
            ]";

            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("evaluator", evaluator);
            jsonParameters.Add("datatype", dataType);
            jsonParameters.Add("cases", JArray.Parse(switchCases));

            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("SwitchMacro", null, variableName, jsonParameters);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            SwitchMacro  macro      = new SwitchMacro();
            IMacroConfig realConfig = macro.CreateConfig(_engineEnvironmentSettings, deferredConfig);

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, realConfig, parameters, setter);
            ITemplateParameter resultParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out resultParam));
            string resultValue = (string)parameters.ResolvedValues[resultParam];

            Assert.Equal(resultValue, expectedValue);
        }
コード例 #12
0
        public void TestGuidConfig()
        {
            string       paramName   = "TestGuid";
            IMacroConfig macroConfig = new GuidMacroConfig(paramName, "string", string.Empty, null);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            GuidMacro guidMacro = new GuidMacro();

            guidMacro.EvaluateConfig(EngineEnvironmentSettings, variables, macroConfig, parameters, setter);
            ValidateGuidMacroCreatedParametersWithResolvedValues(paramName, parameters);
        }
コード例 #13
0
        public void TestDeferredGuidConfig()
        {
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("format", null);
            string variableName = "myGuid1";
            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("GuidMacro", variableName, jsonParameters);

            GuidMacro              guidMacro  = new GuidMacro();
            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            guidMacro.EvaluateDeferredConfig(EngineEnvironmentSettings, variables, deferredConfig, parameters, setter);
            ValidateGuidMacroCreatedParametersWithResolvedValues(variableName, parameters);
        }
コード例 #14
0
        public void TestRegexDeferredConfig()
        {
            string variableName   = "myRegex";
            string sourceVariable = "originalValue";
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("source", sourceVariable);

            string jsonSteps = @"[
                { 
                    'regex': 'A',
                    'replacement': 'Z'
                }
            ]";

            jsonParameters.Add("steps", JArray.Parse(jsonSteps));

            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("RegexMacro", variableName, jsonParameters);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            string    sourceValue   = "ABCAABBCC";
            string    expectedValue = "ZBCZZBBCC";
            Parameter sourceParam   = new Parameter
            {
                IsVariable = true,
                Name       = sourceVariable
            };

            variables[sourceVariable] = sourceValue;
            setter(sourceParam, sourceValue);

            RegexMacro   macro      = new RegexMacro();
            IMacroConfig realConfig = macro.CreateConfig(EngineEnvironmentSettings, deferredConfig);

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, realConfig, parameters, setter);
            ITemplateParameter newParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out newParam));
            string newValue = (string)parameters.ResolvedValues[newParam];

            Assert.Equal(newValue, expectedValue);
        }
コード例 #15
0
        public void TestDeferredJoinConfig(string separator)
        {
            string variableName         = "joinedParameter";
            string referenceSymbolName  = "referenceSymbol";
            string referenceSymbolValue = "referenceValue";
            string constantValue        = "constantValue";

            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();
            string symbols =
                $"[ {{\"type\":\"const\" , \"value\":\"{constantValue}\"  }}, {{\"type\":\"ref\" , \"value\":\"{referenceSymbolName}\"  }} ]";

            jsonParameters.Add("symbols", JArray.Parse(symbols));
            if (!string.IsNullOrEmpty(separator))
            {
                jsonParameters.Add("separator", separator);
            }

            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("JoinMacro", null, variableName, jsonParameters);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new RunnableProjectGenerator.ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            Parameter referenceParam = new Parameter
            {
                IsVariable = true,
                Name       = referenceSymbolName
            };

            variables[referenceSymbolName] = referenceSymbolValue;
            setter(referenceParam, referenceSymbolValue);

            JoinMacro    macro      = new JoinMacro();
            IMacroConfig realConfig = macro.CreateConfig(EngineEnvironmentSettings, deferredConfig);

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, realConfig, parameters, setter);

            Assert.True(parameters.TryGetParameterDefinition(variableName, out ITemplateParameter convertedParam));

            string convertedValue = (string)parameters.ResolvedValues[convertedParam];
            string expectedValue  = string.Join(separator, constantValue, referenceSymbolValue);

            Assert.Equal(convertedValue, expectedValue);
        }
コード例 #16
0
        public void TestJoinConstantAndReferenceSymbolConfig(string separator, bool removeEmptyValues)
        {
            string variableName             = "joinedParameter";
            string referenceSymbolName      = "referenceSymbol";
            string referenceSymbolValue     = "referenceValue";
            string referenceEmptySymbolName = "referenceEmptySymbol";
            string constantValue            = "constantValue";

            List <KeyValuePair <string, string> > definitions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("const", constantValue),
                new KeyValuePair <string, string>("ref", referenceEmptySymbolName),
                new KeyValuePair <string, string>("ref", referenceSymbolName)
            };

            JoinMacroConfig macroConfig = new JoinMacroConfig(variableName, null, definitions, separator, removeEmptyValues);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new RunnableProjectGenerator.ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            Parameter referenceParam = new Parameter
            {
                IsVariable = true,
                Name       = referenceSymbolName
            };

            variables[referenceSymbolName] = referenceSymbolValue;
            setter(referenceParam, referenceSymbolValue);

            JoinMacro macro = new JoinMacro();

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfig, parameters, setter);

            Assert.True(parameters.TryGetParameterDefinition(variableName, out ITemplateParameter convertedParam));

            string convertedValue = (string)parameters.ResolvedValues[convertedParam];
            string expectedValue  =
                removeEmptyValues ?
                string.Join(separator, constantValue, referenceSymbolValue) :
                string.Join(separator, constantValue, null, referenceSymbolValue);

            Assert.Equal(convertedValue, expectedValue);
        }
コード例 #17
0
        public void TestEvaluateConfig(string predicate, bool expectedResult)
        {
            string variableName             = "myPredicate";
            string evaluator                = "C++";
            EvaluateMacroConfig macroConfig = new EvaluateMacroConfig(variableName, predicate, evaluator);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            EvaluateMacro macro = new EvaluateMacro();

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, macroConfig, parameters, setter);
            ITemplateParameter resultParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out resultParam));
            bool resultValue = (bool)parameters.ResolvedValues[resultParam];

            Assert.Equal(resultValue, expectedResult);
        }
コード例 #18
0
        public void TestConstantConfig()
        {
            string variableName             = "myConstant";
            string value                    = "1048576";
            ConstantMacroConfig macroConfig = new ConstantMacroConfig(null, variableName, value);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = A.Fake <IRunnableProjectConfig>();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(_engineEnvironmentSettings, parameters);

            ConstantMacro macro = new ConstantMacro();

            macro.EvaluateConfig(_engineEnvironmentSettings, variables, macroConfig, parameters, setter);

            ITemplateParameter constParameter;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out constParameter));
            string constParamValue = (parameters.ResolvedValues[constParameter]).ToString();

            Assert.Equal(constParamValue, value);
        }
コード例 #19
0
        public void TestRegexMacro()
        {
            string variableName   = "myRegex";
            string sourceVariable = "originalValue";
            IList <KeyValuePair <string, string> > steps = new List <KeyValuePair <string, string> >();

            steps.Add(new KeyValuePair <string, string>("2+", "3"));
            steps.Add(new KeyValuePair <string, string>("13", "Z"));
            RegexMacroConfig macroConfig = new RegexMacroConfig(variableName, sourceVariable, steps);

            IVariableCollection    variables  = new VariableCollection();
            IRunnableProjectConfig config     = new SimpleConfigModel();
            IParameterSet          parameters = new ParameterSet(config);
            ParameterSetter        setter     = MacroTestHelpers.TestParameterSetter(EngineEnvironmentSettings, parameters);

            string sourceValue   = "QQQ121222112";
            string expectedValue = "QQQZZ1Z";

            Parameter sourceParam = new Parameter
            {
                IsVariable = true,
                Name       = sourceVariable
            };

            variables[sourceVariable] = sourceValue;
            setter(sourceParam, sourceValue);

            RegexMacro macro = new RegexMacro();

            macro.EvaluateConfig(EngineEnvironmentSettings, variables, macroConfig, parameters, setter);

            ITemplateParameter newParam;

            Assert.True(parameters.TryGetParameterDefinition(variableName, out newParam));
            string newValue = (string)parameters.ResolvedValues[newParam];

            Assert.Equal(newValue, expectedValue);
        }