Beispiel #1
0
        public void AllWindows_WhenTranslatedWithAllLanguages_DoNotThrowExceptions(string translation)
        {
            var lang = GetLanguage(translation);

            var translationData = Data.CreateDataStorage();
            var iniStorage      = new IniStorage();

            iniStorage.SetData(translationData);
            var translationFile = Path.Combine(_languagePath, lang.FileName);

            iniStorage.ReadData(translationFile, true);

            var exceptionTranslator = new ExceptionTranslator(_translationProxy);

            _translationProxy.Translator = new BasicTranslator(lang.CommonName, translationData);
            _translationProxy.LoadOldSectionNames(translationFile);

            // Do some work to include all resources as we do not have our WPF app context here
            EnsureApplicationResources();

            var container = BuildContainer();

            LoggingHelper.InitConsoleLogger("TranslationTest", LoggingLevel.Off);
            var settingsProvider = container.GetInstance <ISettingsProvider>();

            settingsProvider.Settings.Returns(new PdfCreatorSettings(new IniStorage()));
            settingsProvider.GpoSettings.Returns(new GpoSettingsDefaults());

            // Everything with the type "Window" is tested automatically. If special parameters are needed for a type, they can be declared here

            TestWindows(_translationProxy, lang, container);
            TestActionControls(_translationProxy, lang, container);

            Assert.IsEmpty(exceptionTranslator.TranslationErrors, "There were errors while translating the forms");
        }
Beispiel #2
0
        public void TestEnumTranslationsInEnglish()
        {
            var lang = _translations.FirstOrDefault(l => l.CommonName.Equals("English"));

            Assert.IsNotNull(lang, "Could not load english translation");
            ITranslator trans = new ExceptionTranslator(new BasicTranslator(Path.Combine(_languagePath, lang.FileName)));

            var enumsWithoutTranslation = new List <Type>();

            enumsWithoutTranslation.Add(typeof(EncryptionLevel));  ////Associated radio buttons get translated manually
            enumsWithoutTranslation.Add(typeof(LoggingLevel));

            EnsureApplicationResources();

            //Get assembly which defines the settings
            var assembly = Assembly.GetAssembly(typeof(PdfCreatorSettings));
            //Get all enumTypes in "pdfforge.PDFCreator.Core.Settings.Enums"
            var enumTypes =
                assembly.GetTypes()
                .Where(
                    t =>
                    string.Equals(t.Namespace, "pdfforge.PDFCreator.Core.Settings.Enums",
                                  StringComparison.Ordinal));

            //Remove all enumtypes without translation
            enumTypes = enumTypes.Where(e => !enumsWithoutTranslation.Contains(e));

            foreach (var e in enumTypes)
            {
                var values = Enum.GetValues(e);
                foreach (var v in values)
                {
                    var enumValue = e.Name + "." + v;
                    Assert.IsNotNullOrEmpty(trans.GetTranslation("Enums", enumValue),
                                            enumValue + " has no translation in " + lang.CommonName);
                }
            }
        }