ToString() public méthode

Gets the complete syntax for the command.
The string returned by this method is equivalent to what would be entered in a command prompt.
public ToString ( ) : string
Résultat string
        public void CommandWithTwoParams_NoArgumentProvided_BuildsCorrectly()
        {
            CommandWithTwoParams command = new CommandWithTwoParams();

            string expected = "command";
            SyntaxBuilder target = new SyntaxBuilder(command);
            string actual = target.ToString();

            Assert.AreEqual(expected, actual);
        }
        public void CommandWithRequiredParam_ArgumentNotProvided_ExceptionThrown()
        {
            const int argument1 = 0;
            CommandWithRequiredParam command = new CommandWithRequiredParam();

            string expected = "command --param1 " + argument1.ToString();
            SyntaxBuilder target = new SyntaxBuilder(command);
            string actual = target.ToString();

            Assert.AreEqual(expected, actual);
        }
        public void CommandWithTwoParams_OneArgumentProvided_BuildsCorrectly()
        {
            const int argument1 = 0;
            CommandWithTwoParams command = new CommandWithTwoParams
            {
                Parameter1 = argument1
            };

            string expected = "command --param1 " + argument1.ToString();
            SyntaxBuilder target = new SyntaxBuilder(command);
            string actual = target.ToString();

            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        /// <summary>
        /// Gets the command prompt <see cref="String"/> representation for this <see cref="Command"/>.
        /// </summary>
        /// <returns>A <see cref="String"/> that contains the command prompt representation of this
        /// <see cref="Command"/>.</returns>
        public string GetSyntax()
        {
            SyntaxBuilder syntaxBuilder = new SyntaxBuilder(this);

            return(syntaxBuilder.ToString());
        }
        /// <summary>
        /// Gets the command prompt <see cref="String"/> representation for this <see cref="Command"/>.
        /// </summary>
        /// <returns>A <see cref="String"/> that contains the command prompt representation of this 
        /// <see cref="Command"/>.</returns>
        public string GetSyntax()
        {
            SyntaxBuilder syntaxBuilder = new SyntaxBuilder(this);

            return syntaxBuilder.ToString();
        }