public void ValidEqualitycheckOperation()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text")
                                   .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
                                   .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
                                   .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            var translationGroup2 = new TranslationsGroup("Email_Text")
                                    .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            var translationGroup3 = new TranslationsGroup("Email_Text")
                                    .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            var translationGroup4 = new TranslationsGroup("hello_text")
                                    .Add(new Translation(Languages.English_UnitedStates.Code(), "Hello there"));

            //- Act
            var r1 = translationGroup != translationGroup2;
            var r2 = translationGroup2 == translationGroup3;
            var r3 = translationGroup3 != translationGroup4;

            //- Assert
            Assert.AreEqual(true, r1);
            Assert.AreEqual(true, r2);
            Assert.AreEqual(true, r3);
        }
        public void InValideTranslationGroupNameTest()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("");

            //- Act

            //- Assert
        }
Ejemplo n.º 3
0
        /// <summary>
        /// get the list of translations from the JSON File and
        /// populate the list property in current manager object
        /// and assign file to Translation File priority
        /// </summary>
        /// <param name="file"></param>
        public void GetTranslations()
        {
            var tg = new TranslationsGroup("Hello_text")
                     .Add(new Translation(Languages.English_UnitedStates.Code(), "Hello"))
                     .Add(new Translation(Languages.Spanish_Spain.Code(), "Hola"))
                     .Add(new Translation(Languages.Arabic_Morocco.Code(), "مرحبا"))
                     .Add(new Translation(Languages.Chinese_China.Code(), "你好"))
                     .Add(new Translation(Languages.French_France.Code(), "Salut"));

            TranslationsGroups = new List <TranslationsGroup>()
            {
                tg
            };
        }
        public void ValideTranslationGroupTest()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text");

            //- Act
            translationGroup
            .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
            .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
            .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            //- Assert
            Assert.AreEqual("Email_Text", translationGroup.Name);
            Assert.AreEqual(3, translationGroup.Count);
        }
        public void InValidRemoveTranslationByCodeFromTranslationGroupTest()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text");

            translationGroup
            .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
            .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
            .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            //- Act
            translationGroup.DeleteTranslation("ft-FR");

            //- Assert
        }
        /// <summary>
        /// Add the translation group to the list
        /// </summary>
        /// <param name="translationGroup">translation group to be added</param>
        /// <exception cref="TranslationGroupAlreadyExistException">if the translation group Already Exist</exception>
        public TranslationsGroup Add(TranslationsGroup translationGroup)
        {
            var tg = Find(translationGroup.Name);

            if (tg != null)
            {
                throw new TranslationsGroupAlreadyExistException(translationGroup.Name);
            }

            _db.TranslationsGroups.Add(translationGroup);


            OnDataChanged(ListChangedType.Add, Count - 1, null, translationGroup);
            return(translationGroup);
        }
        public void InValidRemoveTranslationByTranslationFromTranslationGroupTest()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text");
            var translation      = new Translation(Languages.Spanish_Spain.Code(), "¡Introduce tu correo electrónico!");

            translationGroup
            .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
            .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
            .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            //- Act
            translationGroup.DeleteTranslation(translation);

            //- Assert
        }
        public TranslationsGroup Update(TranslationsGroup oldTranslationGroup, TranslationsGroup newTranslationGroup)
        {
            var old = Find(oldTranslationGroup.Name)
                      ?? throw new TranslationsGroupNotExistException(oldTranslationGroup.Name);

            var newT = Find(newTranslationGroup.Name);

            if (!(newT is null))
            {
                throw new TranslationsGroupAlreadyExistException(newTranslationGroup.Name);
            }

            _db.TranslationsGroups[IndexOf(old)] = newTranslationGroup;

            OnDataChanged(ListChangedType.Update, IndexOf(old), old, newTranslationGroup);
            return(old);
        }
        public void InValideTranslationGroupTest()
        {
            //try to add an exiting translation to the translationGroup

            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text")
                                   .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
                                   .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
                                   .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            var translation = new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك");

            //- Act

            translationGroup.Add(translation);

            //- Assert
        }
        public void ValidUpdateTranslationInTranslationGroupTest2()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text");
            var translation      = new Translation(Languages.Spanish_Spain.Code(), "¡Introduce tu correo electrónico!");

            translationGroup
            .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
            .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
            .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"))
            .Add(new Translation(Languages.Spanish_Spain.Code(), "¡Introduce electrónico!"));

            //- Act
            translationGroup.UpdateTranslation(Languages.Arabic_Morocco.Code(), translation);

            //- Assert
            Assert.AreEqual("ادخل الايميل الخاص بك", translationGroup.Find(Languages.Arabic_Morocco.Code()).Value);
            Assert.AreEqual("¡Introduce tu correo electrónico!", translationGroup.Find(Languages.Spanish_Spain.Code()).Value);
        }
        public void ValidCheckLanguageIfExistTranslationInTranslationGroupTest()
        {
            //- Arrange
            var translationGroup = new TranslationsGroup("Email_Text");

            translationGroup
            .Add(new Translation(Languages.English_UnitedStates.Code(), "Enter your Email!"))
            .Add(new Translation(Languages.French_France.Code(), "Entrer votre Email!"))
            .Add(new Translation(Languages.Arabic_Morocco.Code(), "ادخل الايميل الخاص بك"));

            //- Act
            var exist  = translationGroup.HasLanguage(Languages.Arabic_Morocco);
            var exist2 = translationGroup.HasLanguage(Languages.Spanish_Spain.Code());
            var exist3 = translationGroup.HasLanguage("go-GO");

            //- Assert
            Assert.AreEqual(true, exist);
            Assert.AreEqual(false, exist2);
            Assert.AreEqual(false, exist3);
        }
 /// <summary>
 /// determine whether the element exist in the list
 /// </summary>
 /// <param name="item">the TranslationGroup to look for</param>
 /// <returns>true if exist, false if not </returns>
 public bool Contains(TranslationsGroup item)
 {
     return(_db.TranslationsGroups.Contains(item));
 }
 /// <summary>
 /// get the index of the given item
 /// </summary>
 /// <param name="item">the translation Group</param>
 /// <returns>the index</returns>
 public int IndexOf(TranslationsGroup item)
 {
     return(_db.TranslationsGroups.IndexOf(item));
 }
 /// <summary>
 /// Raise the DataSourceChanged Event
 /// </summary>
 /// <param name="listChangedType">the change type</param>
 /// <param name="index">index where the change occur</param>
 /// <param name="oldRecord">the old record</param>
 /// <param name="newRecord">the new record</param>
 private void OnDataChanged(ListChangedType listChangedType, int index, TranslationsGroup oldRecord, TranslationsGroup newRecord)
 {
     _unsavedChanges = true;
     TranslationsGroupsListChanged?
     .Invoke(this, new TranslationsGroupsListChangedEventArgs(listChangedType, index, oldRecord, newRecord));
 }
 /// <summary>
 /// delete the translations Group from the list
 /// </summary>
 /// <param name="item">translation group to be removed</param>
 /// <returns>true if the item deleted, false if not</returns>
 /// <exception cref="TranslationGroupNotExistException">if the translation group not exist</exception>
 public bool Remove(TranslationsGroup item)
 => Remove(item.Name);