Example #1
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());
        }
Example #2
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());
        }