WithUiCulture() public static méthode

public static WithUiCulture ( CultureInfo culture ) : IDisposable
culture System.Globalization.CultureInfo
Résultat IDisposable
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }