Esempio n. 1
0
        public void ReflectionParameters()
        {
            var numCommon = CommonCmdletParameters.ParameterDiscovery.AllParameters.Count;
            CommandParameterSetInfo allSet      = info.GetParameterSetByName(ParameterAttribute.AllParameterSets);
            CommandParameterSetInfo fileSet     = info.GetParameterSetByName("File");
            CommandParameterSetInfo variableSet = info.GetParameterSetByName("Variable");


            Assert.AreEqual(3 + numCommon, allSet.Parameters.Count);
            Assert.AreEqual(4 + numCommon, fileSet.Parameters.Count);
            Assert.AreEqual(5 + numCommon, variableSet.Parameters.Count);

            Assert.IsNotNull(allSet);
            Assert.IsNotNull(fileSet);
            Assert.IsNotNull(variableSet);
            Assert.IsNull(info.GetParameterSetByName("TheseShouldBeSkipped"));

            CheckForAllSetsParameters(allSet);
            CheckForAllSetsParameters(fileSet);
            CheckForAllSetsParameters(variableSet);

            CommandParameterInfo filePathParam = fileSet.GetParameterByName("FilePath");

            Assert.IsNotNull(filePathParam);
            Assert.AreEqual("FilePath", filePathParam.Name);
            Assert.AreEqual(3, filePathParam.Position);
            Assert.AreEqual(true, filePathParam.IsMandatory);

            CommandParameterInfo variableParam = variableSet.GetParameterByName("Variable");

            Assert.IsNotNull(variableParam);
            Assert.AreEqual("Variable", variableParam.Name);
            Assert.AreEqual(0, variableParam.Position);
            Assert.AreEqual(true, variableParam.IsMandatory);

            CommandParameterInfo constVarParam = variableSet.GetParameterByName("ConstVar");

            Assert.IsNotNull(constVarParam);
            Assert.AreEqual("ConstVar", constVarParam.Name);
            Assert.AreEqual(-1, constVarParam.Position);
            Assert.AreEqual(false, constVarParam.IsMandatory);

            CommandParameterInfo ageParam = fileSet.GetParameterByName("Age");

            Assert.IsNull(ageParam);
        }
Esempio n. 2
0
        public void ReflectionParameters()
        {
            CommandParameterSetInfo allSet      = info.GetParameterSetByName(ParameterAttribute.AllParameterSets);
            CommandParameterSetInfo fileSet     = info.GetParameterSetByName("File");
            CommandParameterSetInfo variableSet = info.GetParameterSetByName("Variable");

            Assert.AreEqual(3, allSet.Parameters.Count);
            Assert.AreEqual(4, fileSet.Parameters.Count);
            Assert.AreEqual(4, variableSet.Parameters.Count);

            Assert.IsNotNull(allSet);
            Assert.IsNotNull(fileSet);
            Assert.IsNotNull(variableSet);
            Assert.IsNull(info.GetParameterSetByName("TheseShouldBeSkipped"));

            CheckForAllSetsParameters(allSet);
            CheckForAllSetsParameters(fileSet);
            CheckForAllSetsParameters(variableSet);

            CommandParameterInfo filePathParam = fileSet.GetParameterByName("FilePath");

            Assert.IsNotNull(filePathParam);
            Assert.AreEqual("FilePath", filePathParam.Name);
            Assert.AreEqual(0, filePathParam.Position);
            Assert.AreEqual(true, filePathParam.IsMandatory);

            CommandParameterInfo variableParam = variableSet.GetParameterByName("Variable");

            Assert.IsNotNull(variableParam);
            Assert.AreEqual("Variable", variableParam.Name);
            Assert.AreEqual(-1, variableParam.Position);
            Assert.AreEqual(true, variableParam.IsMandatory);

            CommandParameterInfo ageParam = fileSet.GetParameterByName("Age");

            Assert.IsNull(ageParam);
        }