public void ZodiacSignName() { Program.InitializeEnvironmentStuff(); var langFilePath = TEXT.FindAllLangFiles()["en"]; TEXT.ApplyLanguageFile("en", langFilePath); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 1, 5)), "Capricorn"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 2, 5)), "Aquarius"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 3, 5)), "Pisces"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 4, 20)), "Aries"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 4, 21)), "Taurus"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 6, 5)), "Gemini"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 7, 5)), "Cancer"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 8, 5)), "Leo"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 9, 5)), "Virgo"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 10, 5)), "Libra"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 11, 5)), "Scorpio"); Assert.AreEqual(HoroscopDatePair.GetZodiacSignName(new DateTime(2011, 12, 5)), "Sagittarius"); for (DateTime date = new DateTime(2000, 1, 1); date.Year != 2030; date = date.AddDays(1)) { try { // Make sure this does not crash. HoroscopDatePair.GetZodiacSignName(date); } catch (Exception ex) { Assert.Fail("Unable to take horoscope sign of the day " + date.ToShortDateString()); } } }
public void LoadingPossibility() { Program.InitializeEnvironmentStuff(); var langFiles = TEXT.FindAllLangFiles(); Assert.IsTrue(langFiles.Count >= 3); Assert.IsTrue(TEXT.ApplyLanguageFile(langFiles.First().Key, langFiles.First().Value)); }
public void Brackets() { Program.InitializeEnvironmentStuff(); var langFilePath = TEXT.FindAllLangFiles()["en"]; TEXT.ApplyLanguageFile("en", langFilePath); var list = new TranslationsList() { "Ovulyashki_of" }; Assert.AreEqual(list[0], "Red tides of the princess named {0}"); }
public void AllTextIsTranslated() { var problems = new List <string>(); Program.InitializeEnvironmentStuff(); var langFiles = TEXT.FindAllLangFiles(); Assert.IsTrue(langFiles.Count >= 3); var defaults = TEXT.Get.AllDefaults(); var emptyDefaultValues = defaults.Where(item => string.IsNullOrEmpty(item.Key)).Select(item => item.Value).ToList(); if (emptyDefaultValues.Any()) { problems.Add(string.Format( "In default language '{0}' there is no key for translation(s): {1}.", TEXT.DefaultLang, emptyDefaultValues.Aggregate((s1, s2) => s1 + ", " + s2))); } var emptyDefaultKeys = defaults.Where(item => string.IsNullOrEmpty(item.Value)).Select(item => item.Key).ToList(); if (emptyDefaultKeys.Any()) { problems.Add(string.Format( "In default language '{0}' there is no translation for key(s): {1}.", TEXT.DefaultLang, emptyDefaultKeys.Aggregate((s1, s2) => s1 + ", " + s2))); } foreach (var langItem in langFiles.Where(i => i.Key != TEXT.DefaultLang)) { Assert.IsTrue(TEXT.ApplyLanguageFile(langItem.Key, langItem.Value)); var langFileName = Path.GetFileName(langItem.Value); var translations = TEXT.Get.AllTranslations(); var emptyValues = translations.Where(item => string.IsNullOrEmpty(item.Key)).Select(item => item.Value).ToList(); if (emptyValues.Any()) { problems.Add(string.Format( "In language '{0}' there is no key for translation(s): {1}.", langFileName, emptyValues.Aggregate((s1, s2) => s1 + ", " + s2))); } var emptyKeys = translations.Where(item => string.IsNullOrEmpty(item.Value)).Select(item => item.Key).ToList(); if (emptyKeys.Any()) { problems.Add(string.Format( "In language '{0}' there is no translation for key(s): {1}.", langFileName, emptyKeys.Aggregate((s1, s2) => s1 + ", " + s2))); } if (translations.Count != defaults.Count) { var mismatchKeys = translations.Keys.Count > defaults.Keys.Count ? translations.Keys.Except(defaults.Keys) : defaults.Keys.Except(translations.Keys); problems.Add(string.Format( "Number of translation keys of '{0}' ({3}) mismatch with default language '{1}' ({4}). Mismatch key(s) are: {2}.", langFileName, TEXT.DefaultLang, mismatchKeys.Aggregate((s1, s2) => s1 + ", " + s2), translations.Count, defaults.Count)); } var absentKeys = defaults.Keys.Except(translations.Keys).ToList(); if (absentKeys.Any()) { problems.Add(string.Format( "In file '{0}' there is no translation for key(s): {1}.", langFileName, absentKeys.Aggregate((s1, s2) => s1 + ", " + s2))); } var redundantKeys = translations.Keys.Except(defaults.Keys).ToList(); if (redundantKeys.Any()) { var redundantKeysString = absentKeys.Aggregate((s1, s2) => s1 + ", " + s2); problems.Add(string.Format( "In file '{0}' there is redundant translation for key(s): {1}.", Path.GetFileName(langItem.Value), redundantKeysString)); } } if (problems.Count > 0) { Assert.Fail("We found problems in language file(s):" + Environment.NewLine + problems.Aggregate((s1, s2) => s1 + Environment.NewLine + s2)); } }