Inheritance: System.Management.Automation.PSCmdlet
Ejemplo n.º 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);
            });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
            });
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
            });
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            });
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 17
0
 public void LoadCmdInfo()
 {
     _info   = TestParameterCommand.CreateCmdletInfo();
     _cmdlet = new TestParameterCommand();
     _binder = new CmdletParameterBinder(_info, _cmdlet);
 }
Ejemplo n.º 18
0
 public void LoadCmdInfo()
 {
     info = TestParameterCommand.CreateCmdletInfo();
 }
Ejemplo n.º 19
0
 public void LoadCmdInfo()
 {
     _info = TestParameterCommand.CreateCmdletInfo();
     _cmdlet = new TestParameterCommand();
     _binder = new CmdletParameterBinder(_info, _cmdlet);
 }