public void BindingCombinationAllSet() { CommandProcessor cmdProc = new CommandProcessor(info); TestParameterCommand cmdlet = new TestParameterCommand(); cmdProc.Command = cmdlet; cmdProc.AddParameter("Name", null); cmdProc.AddParameter(null, "John"); cmdProc.AddParameter("Recurse", null); cmdProc.BindArguments(null); Assert.AreEqual("John", cmdlet.Name); Assert.IsTrue(cmdlet.Recurse.ToBool()); }
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()); }
private void DelayedInternalInitialize() { this.pp = new PipelineProcessor(); CmdletInfo cmdletInfo = new CmdletInfo(this.commandName, this.commandType, null, null, this.context); CommandProcessor commandProcessor = new CommandProcessor(cmdletInfo, this.context); foreach (CommandParameterInternal internal2 in this.commandParameterList) { commandProcessor.AddParameter(internal2); } this.pp.Add(commandProcessor); }
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); }
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); }); }
private PipelineProcessor CreatePipelineProcessor() { PipelineProcessor processor2; CommandCollection commands = base.Commands; if ((commands == null) || (commands.Count == 0)) { throw PSTraceSource.NewInvalidOperationException("RunspaceStrings", "NoCommandInPipeline", new object[0]); } PipelineProcessor processor = new PipelineProcessor { TopLevel = true }; bool flag = false; try { foreach (Command command in commands) { CommandProcessorBase base2; if (command.CommandInfo == null) { base2 = command.CreateCommandProcessor(this.LocalRunspace.ExecutionContext, this.LocalRunspace.CommandFactory, base.AddToHistory, this.IsNested ? CommandOrigin.Internal : CommandOrigin.Runspace); } else { CmdletInfo commandInfo = (CmdletInfo) command.CommandInfo; base2 = new CommandProcessor(commandInfo, this.LocalRunspace.ExecutionContext); PSSQMAPI.IncrementData(commandInfo.CommandType); base2.Command.CommandOriginInternal = CommandOrigin.Internal; base2.Command.MyInvocation.InvocationName = commandInfo.Name; if (command.Parameters != null) { foreach (CommandParameter parameter in command.Parameters) { CommandParameterInternal internal2 = CommandParameter.ToCommandParameterInternal(parameter, false); base2.AddParameter(internal2); } } } base2.RedirectShellErrorOutputPipe = base.RedirectShellErrorOutputPipe; processor.Add(base2); } processor2 = processor; } catch (RuntimeException) { flag = true; throw; } catch (Exception exception) { flag = true; CommandProcessorBase.CheckForSevereException(exception); throw new RuntimeException(PipelineStrings.CannotCreatePipeline, exception); } finally { if (flag) { base.SetHadErrors(true); processor.Dispose(); } } return processor2; }
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()); }
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); }
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); }); }
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()); }
private void DelayedInternalInitialize() { _pp = new PipelineProcessor(); CmdletInfo cmdletInfo = new CmdletInfo(_commandName, _commandType, null, null, _context); CommandProcessor cp = new CommandProcessor(cmdletInfo, _context); foreach (CommandParameterInternal par in _commandParameterList) { cp.AddParameter(par); } _pp.Add(cp); }