Exemple #1
0
        public void SupportMultipleCountriesWithSameLanguageWhenConvertingToWords()
        {
            CultureInfo[]
            cultures = new CultureInfo[] { new CultureInfo("en"), new CultureInfo("en-CA"), new CultureInfo("en-US"), new CultureInfo("en-GB") };

            foreach (CultureInfo culture in cultures)
            {
                NumericToWordsConverter converter = new NumericToWordsConverter(new InteiroSemFormato(), culture);
                string result = converter.ToWords(13L);
                Assert.AreEqual(result, "thirteen");
            }
        }
Exemple #2
0
        public void UseBrazilianLocaleWhenConvertingToWordsWithoutLocale()
        {
            CultureInfo defaultLocale = CultureInfo.DefaultThreadCurrentCulture;

            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");

            try
            {
                NumericToWordsConverter converter = new NumericToWordsConverter(new InteiroSemFormato());

                string result = converter.ToWords(13L);
                Assert.AreEqual(result, "treze");
            }
            finally
            {
                CultureInfo.DefaultThreadCurrentCulture = defaultLocale;
            }
        }
Exemple #3
0
        public void ShouldTransformNegativeLong()
        {
            long negative = -1;

            converter.ToWords(negative);
        }
Exemple #4
0
        public void ThrowExceptionWhenConvertingToWordsWithUnsupportedLanguage()
        {
            NumericToWordsConverter converter = new NumericToWordsConverter(new InteiroSemFormato(), new CultureInfo("jp-JP"));

            converter.ToWords(13L);
        }
Exemple #5
0
        public void ShouldTransform0InWords()
        {
            double zero   = 0;
            string actual = converter.ToWords(zero);

            Assert.AreEqual("zero", actual);
        }