示例#1
0
        public void ShowHelp_WithAmericanLocale_ShowsEnglishHelpText()
        {
            using (LocalizationExtensions.WithUiCulture(new CultureInfo("en-US")))
            {
                // Arrange
                var expected = @"Usage: clipr [ -h|--help ] [ --version ] [ --turnonthepower ] [ -s S ] [ -c C ] FILETOADD
Positional Arguments:
 FileToAdd         File to add to the thing.

Optional Arguments:
 --turnonthepower  Set power level to 9001.
 -c                A cool counter.
 -h, --help        Display this help document.
 -s                Start date.
 --version         Displays the version of the current executable.";

                var opt    = new LocalizationOptions();
                var parser = new CliParser <LocalizationOptions>(opt);
                var help   = new AutomaticHelpGenerator <LocalizationOptions>(); // TODO simplify work required to get help info

                // Act
                var actual = help.GetHelp(parser.Config);

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
示例#2
0
        public void ShowHelp_WithMexicanLocale_ShowsSpanishHelpText()
        {
            using (LocalizationExtensions.WithUiCulture(new CultureInfo("es-MX")))
            {
                // Arrange
                var expected = @"Forma de uso: clipr [ -h|--help ] [ --version ] [ --turnonthepower ] [ -s S ] [ -c C ] FILETOADD
Argumentos dependientes de la posición:
 FileToAdd         Archivo para añadir a la cosa.

Argumentos opcionales:
 --turnonthepower  Establecer el nivel de potencia de 9001.
 -c                Un contador fresco.
 -h, --help        Muestra esta ayuda
 -s                Fecha de inicio.
 --version         Muestra la versión del ejecutable";

                var opt    = new LocalizationOptions();
                var parser = new CliParser <LocalizationOptions>(opt);
                var help   = new AutomaticHelpGenerator <LocalizationOptions>();

                // Act
                var actual = help.GetHelp(parser.Config);

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
示例#3
0
        public void ParseDate_WithMexicanLocaleAndMexicanDateFormat_ParsesDateCorrectly()
        {
            using (LocalizationExtensions.WithUiCulture(new CultureInfo("es-MX")))
            {
                // Arrange
                var expected = new DateTime(2016, 3, 12);

                var opt    = new LocalizationOptions();
                var parser = new CliParser <LocalizationOptions>(opt);
                var help   = new AutomaticHelpGenerator <LocalizationOptions>();

                // Act
                parser.Parse("-s 12/3/2016 file.txt".Split());

                // Assert
                Assert.AreEqual(expected, opt.StartDate);
            }
        }
示例#4
0
        public void ParseNumber_WithSpanishLocaleAndSpanishNumberFormat_ParsesNumberCorrectly()
        {
            using (LocalizationExtensions.WithUiCulture(new CultureInfo("es-ES")))
            {
                // Arrange
                var expected = 2.3;

                var opt    = new LocalizationOptions();
                var parser = new CliParser <LocalizationOptions>(opt);
                var help   = new AutomaticHelpGenerator <LocalizationOptions>();

                // Act
                parser.Parse("-c 2,3 file.txt".Split());

                // Assert
                Assert.AreEqual(expected, opt.MyCounter);
            }
        }