Ejemplo n.º 1
0
        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));
            });
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void TestDeferredGuidConfig()
        {
            Dictionary <string, JToken> jsonParameters = new Dictionary <string, JToken>();

            jsonParameters.Add("format", null);
            string variableName = "myGuid1";
            GeneratedSymbolDeferredMacroConfig deferredConfig = new GeneratedSymbolDeferredMacroConfig("GuidMacro", "string", 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);

            IMacroConfig realConfig = guidMacro.CreateConfig(EngineEnvironmentSettings, deferredConfig);

            guidMacro.EvaluateConfig(EngineEnvironmentSettings, variables, realConfig, parameters, setter);
            ValidateGuidMacroCreatedParametersWithResolvedValues(variableName, parameters);
        }