Esempio n. 1
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);
        }
Esempio n. 2
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);
        }