Exemplo n.º 1
0
            public void ShouldSplitExceptInQuotes(string arguments, string[] expected)
            {
                // Given, When
                IEnumerable <string> actual = ArgumentSplitter.Split(arguments);

                // Then
                CollectionAssert.AreEqual(expected, actual);
            }
            public void ShouldSplitExceptInQuotes(string arguments, string[] expected)
            {
                // Given, When
                IEnumerable <string> actual = ArgumentSplitter.Split(arguments);

                // Then
                actual.ShouldBe(expected);
            }
Exemplo n.º 3
0
        private string Process(Configurator configurator, string value, bool getHelpText)
        {
            // Parse the directive value
            IEnumerable <string> arguments = ArgumentSplitter.Split(value);
            ArgumentSyntax       parsed    = null;
            string    helpText             = null;
            TSettings settings             = new TSettings();

            try
            {
                parsed = ArgumentSyntax.Parse(arguments, syntax =>
                {
                    syntax.HandleErrors = !getHelpText;
                    Define(syntax, settings);
                    if (getHelpText)
                    {
                        helpText = syntax.GetHelpText();
                    }
                });
            }
            catch (Exception)
            {
                if (!getHelpText)
                {
                    throw;
                }
            }
            if (getHelpText)
            {
                return(helpText);
            }
            if (parsed.HasErrors)
            {
                throw new Exception(parsed.GetHelpText());
            }

            Process(configurator, settings);
            return(string.Empty);
        }