コード例 #1
0
        public void testBackwardsLanguage()
        {
            LanguageList list = getLanguageList();

            Assert.NotNull(list);
            Assert.IsTrue(list.languages.Count > 0);

            TransfluentLanguage englishLanguage = list.getLangaugeByCode("en-us");
            TransfluentLanguage lang            = list.getLangaugeByCode(TransfluentLanguage.BACKWARDS_LANGUAGE_NAME);

            Assert.AreNotEqual(englishLanguage.code, 0);
            Assert.NotNull(lang);

            //post text key
            string textToSave = "this is sample text" + Random.value;
            var    saveOp     = new SaveTextKey
                                (
                language: englishLanguage.id,
                text: textToSave,
                text_id: HELLO_WORLD_TEXT_KEY
                                );
            bool saved = saveOp.Parse(justCall(saveOp));

            Debug.Log("Saved successfullly:" + saved);

            var testForExistance = new GetTextKey
                                   (
                languageID: englishLanguage.id,
                text_id: HELLO_WORLD_TEXT_KEY
                                   );
            string keyFromDB = testForExistance.Parse(justCall(testForExistance));

            Assert.IsFalse(string.IsNullOrEmpty(keyFromDB));
            Assert.AreEqual(textToSave, keyFromDB);
        }
コード例 #2
0
        public void THIS_FAILS_testAlreadyInsertedException()
        {
            string textToSave = textToSetTestTokenTo + Random.value;
            var    saveOp     = new SaveTextKey
                                (
                language: englishLanguage.id,
                text: textToSave,
                text_id: TRANSLATION_KEY
                                );

            justCall(saveOp);
            justCall(saveOp);             //error 500, this looks like a temporary server error...
        }
コード例 #3
0
        public void SetText(string textKey, string textValue, string groupKey = null)
        {
            if (currentLanguage == null)
            {
                throw new Exception("Must set current language first!");
            }
            var saveText = new SaveTextKey
                               (textKey,
                               text: textValue,
                               group_id: groupKey,
                               language: currentLanguage.id);

            try
            {
                makeCall(saveText);
            }
            catch (CallException exception)
            {
                Debug.LogError("error making setText call:" + exception.Message);
            }
        }
コード例 #4
0
        public void SaveRetrieveKey(string keyToSaveAndThenGet, TransfluentLanguage language)
        {
            //post text key
            string textToSave = textToSetTestTokenTo + Random.value;
            var    saveOp     = new SaveTextKey
                                (
                language: language.id,
                text: textToSave,
                text_id: keyToSaveAndThenGet
                                );
            string callText = justCall(saveOp);

            Assert.IsTrue(saveOp.Parse(callText));
            var testForExistance = new GetTextKey
                                   (
                languageID: language.id,
                text_id: keyToSaveAndThenGet
                                   );
            string stringFromServer = testForExistance.Parse(justCall(testForExistance));

            Assert.IsFalse(string.IsNullOrEmpty(stringFromServer));
            Assert.AreEqual(textToSave, stringFromServer);

            //save it back to what we expect it to be
            saveOp = new SaveTextKey
                     (
                language: language.id,
                text: textToSetTestTokenTo,
                text_id: keyToSaveAndThenGet
                     );
            callText = justCall(saveOp);
            Assert.IsTrue(saveOp.Parse(callText));

            stringFromServer = testForExistance.Parse(justCall(testForExistance));
            Assert.AreEqual(textToSetTestTokenTo, stringFromServer);
        }
コード例 #5
0
        public void testBackwardsLanguage()
        {
            LanguageList list = getLanguageList();
            Assert.NotNull(list);
            Assert.IsTrue(list.languages.Count > 0);

            TransfluentLanguage englishLanguage = list.getLangaugeByCode("en-us");
            TransfluentLanguage lang = list.getLangaugeByCode(TransfluentLanguage.BACKWARDS_LANGUAGE_NAME);
            Assert.AreNotEqual(englishLanguage.code, 0);
            Assert.NotNull(lang);

            //post text key
            string textToSave = "this is sample text" + Random.value;
            var saveOp = new SaveTextKey
                (
                language: englishLanguage.id,
                text: textToSave,
                text_id: HELLO_WORLD_TEXT_KEY
                );
            bool saved = saveOp.Parse(justCall(saveOp));
            Debug.Log("Saved successfullly:" + saved);

            var testForExistance = new GetTextKey
                (
                languageID: englishLanguage.id,
                text_id: HELLO_WORLD_TEXT_KEY
                );
            string keyFromDB = testForExistance.Parse(justCall(testForExistance));
            Assert.IsFalse(string.IsNullOrEmpty(keyFromDB));
            Assert.AreEqual(textToSave, keyFromDB);
        }
コード例 #6
0
 public void SetText(string textKey, string textValue, string groupKey = null)
 {
     if(currentLanguage == null) throw new Exception("Must set current language first!");
     var saveText = new SaveTextKey
         (textKey,
             text: textValue,
             group_id: groupKey,
             language: currentLanguage.id);
     try
     {
         makeCall(saveText);
     }
     catch(CallException exception)
     {
         Debug.LogError("error making setText call:" + exception.Message);
     }
 }
コード例 #7
0
 public void THIS_FAILS_testAlreadyInsertedException()
 {
     string textToSave = textToSetTestTokenTo + Random.value;
     var saveOp = new SaveTextKey
         (
         language: englishLanguage.id,
         text: textToSave,
         text_id: TRANSLATION_KEY
         );
     justCall(saveOp);
     justCall(saveOp); //error 500, this looks like a temporary server error...
 }
コード例 #8
0
        public void SaveRetrieveKey(string keyToSaveAndThenGet, TransfluentLanguage language)
        {
            //post text key
            string textToSave = textToSetTestTokenTo + Random.value;
            var saveOp = new SaveTextKey
                (
                language: language.id,
                text: textToSave,
                text_id: keyToSaveAndThenGet
                );
            string callText = justCall(saveOp);
            Assert.IsTrue(saveOp.Parse(callText));
            var testForExistance = new GetTextKey
                (
                languageID: language.id,
                text_id: keyToSaveAndThenGet
                );
            string stringFromServer = testForExistance.Parse(justCall(testForExistance));

            Assert.IsFalse(string.IsNullOrEmpty(stringFromServer));
            Assert.AreEqual(textToSave, stringFromServer);

            //save it back to what we expect it to be
            saveOp = new SaveTextKey
                (
                language: language.id,
                text: textToSetTestTokenTo,
                text_id: keyToSaveAndThenGet
                );
            callText = justCall(saveOp);
            Assert.IsTrue(saveOp.Parse(callText));

            stringFromServer = testForExistance.Parse(justCall(testForExistance));
            Assert.AreEqual(textToSetTestTokenTo, stringFromServer);
        }