Exemple #1
0
        public void BindingParameterAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Path", "a path");

            cmdProc.BindArguments(null);

            Assert.AreEqual("a path", cmdlet.FilePath.ToString());
        }
Exemple #2
0
        public void BindingAmbiguous()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("i", 10);

            Assert.Throws(typeof(ArgumentException), delegate() {
                cmdProc.BindArguments(null);
            });
        }
Exemple #3
0
        public void BindingParameter()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("InputObject", 10);

            cmdProc.BindArguments(null);

            Assert.AreEqual("10", cmdlet.InputObject.ToString());
        }
Exemple #4
0
        public void BindingFieldAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("fn", "John");

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
        }
Exemple #5
0
        public void BindingParameterSetSelectionSingleAlias()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("PSPath", null);
            cmdProc.AddParameter(null, "a path");

            cmdProc.BindArguments(null);

            Assert.AreEqual("File", cmdlet.ParameterSetName);
        }
Exemple #6
0
        public void BindingNonSwitch()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Name", null);
            cmdProc.AddParameter(null, "John");

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
            Assert.IsFalse(cmdlet.Recurse.ToBool());
        }
Exemple #7
0
        public void BindingCombinationNonDefaultSet()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Variable", "a");
            cmdProc.AddParameter("Recurse", null);

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
            Assert.AreEqual("a path", cmdlet.FilePath);
            Assert.IsTrue(cmdlet.Recurse.ToBool());
        }
Exemple #8
0
        public void BindingParameterSetSelectionDoubleShouldFail()
        {
            CommandProcessor     cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet  = new TestParameterCommand();

            cmdProc.Command = cmdlet;

            cmdProc.AddParameter("Variable", null);
            cmdProc.AddParameter(null, "test");
            cmdProc.AddParameter("FilePath", null);
            cmdProc.AddParameter(null, "a path");

            Assert.Throws(typeof(Exception), delegate()
            {
                cmdProc.BindArguments(null);
            });
        }