public override void Execute(object sender, EventArgs args)
        {
            ParamBlockAst scriptParameters = ParameterEditorHelper.GetScriptParameters(_adaptersFactory, _textManager);

            ScriptArgs = ParameterEditorHelper.PromptForScriptParameterValues(scriptParameters);

            if (ScriptArgs.ShouldExecute)
            {
                base.Execute(sender, args);
            }
        }
Ejemplo n.º 2
0
        public void ShouldGeneratedCorrectScriptArgsBasedOnPartiallyGivenValues()
        {
            var model = new ParameterEditorModel(
                new ObservableCollection <ScriptParameterViewModel>()
            {
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "StringType",
                    Type         = DataTypeConstants.StringType,
                    DefaultValue = null
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "CharType",
                    Type         = DataTypeConstants.CharType,
                    DefaultValue = "C"
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "ByteType",
                    Type         = DataTypeConstants.ByteType,
                    DefaultValue = null
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "IntType",
                    Type         = DataTypeConstants.Int32Type,
                    DefaultValue = 1111
                })
            },

                PowerShellParseUtilities.GenerateCommonParameters());

            string actualScriptArgs   = ParameterEditorHelper.GenerateScripArgsFromModel(model);
            string expectedScriptArgs = " -CharType \"C\" -IntType 1111";

            Assert.AreEqual <string>(expectedScriptArgs, actualScriptArgs);
        }
Ejemplo n.º 3
0
        public void ShouldGeneratedEmptyScriptArgsWhenNoValueIsGiven()
        {
            var model = new ParameterEditorModel(
                new ObservableCollection <ScriptParameterViewModel>()
            {
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "StringType",
                    Type         = DataTypeConstants.StringType,
                    DefaultValue = null
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "CharType",
                    Type         = DataTypeConstants.CharType,
                    DefaultValue = null
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "ByteType",
                    Type         = DataTypeConstants.ByteType,
                    DefaultValue = null
                }),
                new ScriptParameterViewModel(new ScriptParameter()
                {
                    Name         = "IntType",
                    Type         = DataTypeConstants.Int32Type,
                    DefaultValue = null
                })
            },

                PowerShellParseUtilities.GenerateCommonParameters());

            string actualScriptArgs = ParameterEditorHelper.GenerateScripArgsFromModel(model);

            Assert.AreEqual <string>(String.Empty, actualScriptArgs);
        }