Inheritance: System.Management.Automation.PSCmdlet
示例#1
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);
            });
        }
示例#2
0
        public void BindingField()
        {
            CommandProcessor cmdProc = new CommandProcessor(info);
            TestParameterCommand cmdlet = new TestParameterCommand();
            cmdProc.Command = cmdlet;

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

            cmdProc.BindArguments(null);

            Assert.AreEqual("John", cmdlet.Name);
        }
示例#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());
        }
示例#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);
        }
示例#5
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());
        }
示例#6
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);
            });
        }
示例#7
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);
        }
示例#8
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());
        }
示例#9
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());
        }
示例#10
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());
        }
示例#11
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());
        }
示例#12
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);
            });
        }
示例#13
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());
        }
示例#14
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);
        }
示例#15
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);
            });
        }
示例#16
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());
        }
示例#17
0
 public void LoadCmdInfo()
 {
     _info   = TestParameterCommand.CreateCmdletInfo();
     _cmdlet = new TestParameterCommand();
     _binder = new CmdletParameterBinder(_info, _cmdlet);
 }
示例#18
0
 public void LoadCmdInfo()
 {
     info = TestParameterCommand.CreateCmdletInfo();
 }
示例#19
0
 public void LoadCmdInfo()
 {
     _info = TestParameterCommand.CreateCmdletInfo();
     _cmdlet = new TestParameterCommand();
     _binder = new CmdletParameterBinder(_info, _cmdlet);
 }