ToParameterBase() public method

public ToParameterBase ( ) : ThoughtWorks.CruiseControl.Remote.Parameters.ParameterBase
return ThoughtWorks.CruiseControl.Remote.Parameters.ParameterBase
        public void TestBooleanParameter()
        {
            var xml = @"<parameterDefinition>
                        <defaultParameterValue>
                        <value>true</value>
                        </defaultParameterValue>
                        <description>Select a checkbox option</description>
                        <name>BOOLEAN.1</name>
                        <type>BooleanParameterDefinition</type>
                        </parameterDefinition>";

            var xDoc = XDocument.Parse(xml).Descendants().First();
            var boolean = new BooleanParameter(xDoc);

            Assert.AreEqual(boolean.Name, "BOOLEAN.1");
            Assert.AreEqual(boolean.Description, "Select a checkbox option");
            Assert.AreEqual(boolean.ParameterType, BuildParameterType.BooleanParameterDefinition);
            Assert.AreEqual(boolean.DefaultValue, "true");

            // Check the ParameterBase values
            var ccNetBooleanParameter = boolean.ToParameterBase();
        }
Beispiel #2
0
        private List <ParameterBase> GetBuildParameters(XDocument xDoc)
        {
            // Construct the build parameters
            var buildParameters = new List <ParameterBase>();
            var parametersNodes = xDoc.Descendants("action").Elements("parameterDefinition");
            var supportedTypes  = Enum.GetNames(typeof(BuildParameterType));

            foreach (var parameterNode in parametersNodes)
            {
                var type = (string)parameterNode.Element("type");
                if (!supportedTypes.Contains(type))
                {
                    continue;
                }

                switch ((BuildParameterType)Enum.Parse(typeof(BuildParameterType), type))
                {
                case BuildParameterType.BooleanParameterDefinition:
                    var booleanBuildParamter = new BuildParameters.BooleanParameter(parameterNode);
                    buildParameters.Add(booleanBuildParamter.ToParameterBase());
                    break;

                case BuildParameterType.ChoiceParameterDefinition:
                    var choiceBuildParameter = new ChoiceParameter(parameterNode);
                    buildParameters.Add(choiceBuildParameter.ToParameterBase());
                    break;

                case BuildParameterType.StringParameterDefinition:
                    var stringBuildParameter = new StringParameter(parameterNode);
                    buildParameters.Add(stringBuildParameter.ToParameterBase());
                    break;
                }
            }

            return(buildParameters);
        }
Beispiel #3
0
        private List<ParameterBase> GetBuildParameters(XDocument xDoc)
        {
            // Construct the build parameters
            var buildParameters = new List<ParameterBase>();
            var parametersNodes = xDoc.Descendants("action").Elements("parameterDefinition");
            var supportedTypes = Enum.GetNames(typeof(BuildParameterType));
            foreach (var parameterNode in parametersNodes)
            {
                var type = (string)parameterNode.Element("type");
                if (!supportedTypes.Contains(type)) continue;

                switch ((BuildParameterType)Enum.Parse(typeof(BuildParameterType), type))
                {
                    case BuildParameterType.BooleanParameterDefinition:
                        var booleanBuildParamter = new BuildParameters.BooleanParameter(parameterNode);
                        buildParameters.Add(booleanBuildParamter.ToParameterBase());
                        break;

                    case BuildParameterType.ChoiceParameterDefinition:
                        var choiceBuildParameter = new ChoiceParameter(parameterNode);
                        buildParameters.Add(choiceBuildParameter.ToParameterBase());
                        break;

                    case BuildParameterType.StringParameterDefinition:
                        var stringBuildParameter = new StringParameter(parameterNode);
                        buildParameters.Add(stringBuildParameter.ToParameterBase());
                        break;
                }
            }

            return buildParameters;
        }