Пример #1
0
        public void CheckAllCulture()
        {
            ITranslationProvider translationProvider = new TranslationProvider();

            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

            foreach (var countryCode in (Alpha2Code[])Enum.GetValues(typeof(Alpha2Code)))
            {
                var countryTranslation = translationProvider.GetCountryTranslation(countryCode);
                if (countryTranslation == null)
                {
                    continue;
                }

                var expectedLanguages = countryTranslation.Translations.Select(x => x.LanguageCode).ToList();
                foreach (var culture in cultures)
                {
                    bool expectResult = false;
                    if (Enum.TryParse(culture.TwoLetterISOLanguageName, true, out LanguageCode code))
                    {
                        expectResult = expectedLanguages.Any(x => x == code);
                    }

                    var translatedCountryName = translationProvider.GetCountryTranslatedName(countryCode, culture);
                    if (expectResult && string.IsNullOrWhiteSpace(translatedCountryName))
                    {
                        Assert.Fail($"A result was expected but there was no translated country name found for {countryCode} and culture {culture.Name} (language {culture.TwoLetterISOLanguageName})");
                    }
                }
            }
        }
Пример #2
0
        public void GetCountryTranslatedName()
        {
            ITranslationProvider translationProvider = new TranslationProvider();

            var translatedCountryName = translationProvider.GetCountryTranslatedName(Alpha2Code.DE, LanguageCode.EN);

            Assert.AreEqual("Germany", translatedCountryName);
        }