Esempio n. 1
0
        public void UpdateOrCreate_WithTranslatedPluralString_UpdatesTranslation()
        {
            var translation = new TestTranslation();

            translation.Messages[0] = "SOME_TRANSLATED_TEXT";

            translation = _translationFactory.UpdateOrCreateTranslation(translation);

            Assert.Equal(_defaultTranslation.Messages[0], translation.Messages[0]);
        }
Esempio n. 2
0
        public void UpdateOrCreate_WithTranslatedSingularString_UpdatesTranslation()
        {
            var translation = new TestTranslation();

            translation.NextMail = "SOME_TRANSLATED_TEXT";

            translation = _translationFactory.UpdateOrCreateTranslation(translation);

            Assert.Equal(_defaultTranslation.NextMail, translation.NextMail);
        }
Esempio n. 3
0
        public void UpdateOrCreateTranslation_WhenUpdatingSameObjectTwice_DoesNotUpdateSecondTime()
        {
            var translation  = new TestTranslation();
            var expectedText = "SOME_TRANSLATION";

            _cachedTranslationFactory.UpdateOrCreateTranslation(translation);
            // change some text to test the caching
            translation.NextMail = expectedText;
            _cachedTranslationFactory.UpdateOrCreateTranslation(translation);

            Assert.Equal(expectedText, translation.NextMail);
        }
Esempio n. 4
0
        public void UpdateOrCreate_WithTranslatedEnumArray_UpdatesTranslation()
        {
            var expectedTranslation = "SOME_TRANSLATED_TEXT";
            var translation         = new TestTranslation();
            var translatedArray     = translation.TestValues;
            var firstTranslatedItem = translation.TestValues[0];

            _catalog.Translations.Add(_defaultTranslation.TestValues[0].Translation, new[] { expectedTranslation });

            var updatedTranslation = _translationFactory.UpdateOrCreateTranslation(translation);

            Assert.Same(translation, updatedTranslation);
            Assert.Same(translatedArray, updatedTranslation.TestValues);
            Assert.Same(firstTranslatedItem, updatedTranslation.TestValues[0]);
            Assert.Equal(expectedTranslation, updatedTranslation.TestValues[0].Translation);
        }
Esempio n. 5
0
 public TranslationFactoryTest()
 {
     _catalog            = new Catalog();
     _translationFactory = new TranslationFactory(new GettextTranslationSource(_catalog));
     _defaultTranslation = new TestTranslation();
 }