public void testLanguageListGetterWithNoList() { //LanguageList list = ResourceLoadAdapter.getLanguageList(); //Assets/Transfluent/Resources/LanguageList.asset string languageListPath = "Assets/Transfluent/Resources/LanguageList.asset"; AssetDatabase.DeleteAsset(languageListPath); IWebService service = new SyncronousEditorWebRequest(); var request = new RequestAllLanguages(); WebServiceReturnStatus status = service.request(request); LanguageList list = request.Parse(status.text); Assert.NotNull(list); Assert.NotNull(list.languages); Assert.Greater(list.languages.Count, 0); var so = ResourceCreator.CreateSO<LanguageListSO>("LanguageList"); so.list = list; EditorUtility.SetDirty(so); LanguageList newList = ResourceLoadFacade.getLanguageList(); //NOTE: THIS IS THE RUNTIME VERSION... not the editor time version AssetDatabase.SaveAssets(); //manual load var fromDisk = AssetDatabase.LoadAssetAtPath(languageListPath, typeof(LanguageListSO)) as LanguageListSO; Assert.NotNull(fromDisk); Assert.NotNull(fromDisk.list); Assert.NotNull(fromDisk.list.languages); Assert.Greater(fromDisk.list.languages.Count, 0); Debug.Log("newlist:" + JsonWriter.Serialize(newList)); }
public void testSyncronousWebService() { IWebService service = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = service.request("https://transfluent.com/v2/hello/world"); Assert.AreEqual(result.httpErrorCode, 0); Assert.NotNull(result.text); Assert.Greater(result.text.Length, 0); }
public void testSyncronousWebService() { IWebService service = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = service.request("https://transfluent.com/v2/hello/world"); Assert.AreEqual(result.httpErrorCode, 0); Assert.NotNull(result.text); Assert.Greater(result.text.Length, 0); }
public void testTranslation() { var translateRequest = new OrderTranslation(englishLanguage.id, new[] { backwardsLanguage.id }, new[] { TRANSLATION_KEY }); OrderTranslation.TextsTranslateResult translationResult = translateRequest.Parse(justCall(translateRequest)); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = requester.request(translateRequest); Debug.Log("Full result from test translation:" + JsonWriter.Serialize(result.text)); Assert.IsTrue(translationResult.word_count > 0); }
private LanguageList getLanguageList() { var language = new RequestAllLanguages(); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus status = requester.request(language); LanguageList list = language.Parse(status.text); Assert.NotNull(list); Assert.IsTrue(list.languages.Count > 0); return(list); }
public string justCall(WebServiceParameters call) { if(call.getParameters.ContainsKey("token")) call.getParameters.Remove("token"); call.getParameters.Add("token", accessToken); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = requester.request(call); if(result.httpErrorCode > 0) { throw new HttpErrorCode(result.httpErrorCode); } return result.text; }
public void getLanguages() { var language = new RequestAllLanguages(); var requester = new SyncronousEditorWebRequest(); LanguageList list = language.Parse(requester.request(language).text); Assert.NotNull(list); englishLanguage = list.getLangaugeByCode("en-us"); backwardsLanguage = list.getLangaugeByCode(TransfluentLanguage.BACKWARDS_LANGUAGE_NAME); languageCache = list; Assert.AreNotEqual(englishLanguage.code, 0); Assert.NotNull(backwardsLanguage); }
public void getLanguages() { var language = new RequestAllLanguages(); var requester = new SyncronousEditorWebRequest(); LanguageList list = language.Parse(requester.request(language).text); Assert.NotNull(list); englishLanguage = list.getLangaugeByCode("en-us"); backwardsLanguage = list.getLangaugeByCode(TransfluentLanguage.BACKWARDS_LANGUAGE_NAME); languageCache = list; Assert.AreNotEqual(englishLanguage.code, 0); Assert.NotNull(backwardsLanguage); }
//[MenuItem("Transfluent/test full loop english content")] public static void getTestSaveEnglishContent() { var list = ResourceLoadFacade.getLanguageList(); GameTranslationSet source = GameTranslationGetter.GetTranslaitonSetFromLanguageCode("en-us"); var sender = new FileBasedSend(); var contents = sender.SendFileContents(source.getGroup().getDictionaryCopy(), list.getLangaugeByCode("en-us"), "", ""); Debug.Log("Contents :" + contents); TransfluentEditorWindowMediator mediator = new TransfluentEditorWindowMediator(); mediator.doAuth(); string authToken = mediator.getCurrentAuthToken(); string fileIdentifier = "testfile"; var sourceLang = list.getLangaugeByCode("en-us"); var saveCall = new FileBasedSaveCall(fileIdentifier, sourceLang.id, authToken, contents); var caller = new SyncronousEditorWebRequest(); var returnStatus = caller.request(saveCall); Debug.Log("saved file return status:"); Debug.Log(JsonWriter.Serialize(returnStatus)); Debug.Log("auth token:" + authToken); var translateRequest = new FileTranslate("", new int[] { 3, 4 }, OrderTranslation.TranslationQuality.NATIVE_SPEAKER, fileIdentifier, sourceLang.id, authToken); var translateReturn = caller.request(translateRequest); Debug.Log("translate request file:"); Debug.Log(JsonWriter.Serialize(translateReturn)); var translateResultRequest = new FileBasedRead(fileIdentifier, sourceLang.id, authToken); var translateResultReturn = caller.request(translateResultRequest); Debug.Log("translate resulting file:"); Debug.Log(JsonWriter.Serialize(translateResultReturn)); }
public string justCall(WebServiceParameters call) { if (call.getParameters.ContainsKey("token")) { call.getParameters.Remove("token"); } call.getParameters.Add("token", accessToken); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = requester.request(call); if (result.httpErrorCode > 0) { throw new HttpErrorCode(result.httpErrorCode); } return(result.text); }
private WebServiceReturnStatus doCall(WebServiceParameters call) { IWebService req = new SyncronousEditorWebRequest(); try { call.getParameters.Add("token", _token); WebServiceReturnStatus result = req.request(call); return(result); } catch (HttpErrorCode code) { Debug.Log(code.code + " http error"); throw; } }
public void testLanguageListGetterWithNoList() { //LanguageList list = ResourceLoadAdapter.getLanguageList(); //Assets/Transfluent/Resources/LanguageList.asset string languageListPath = "Assets/Transfluent/Resources/LanguageList.asset"; AssetDatabase.DeleteAsset(languageListPath); IWebService service = new SyncronousEditorWebRequest(); var request = new RequestAllLanguages(); WebServiceReturnStatus status = service.request(request); LanguageList list = request.Parse(status.text); Assert.NotNull(list); Assert.NotNull(list.languages); Assert.Greater(list.languages.Count, 0); var so = ResourceCreator.CreateSO <LanguageListSO>("LanguageList"); so.list = list; EditorUtility.SetDirty(so); LanguageList newList = ResourceLoadFacade.getLanguageList(); //NOTE: THIS IS THE RUNTIME VERSION... not the editor time version AssetDatabase.SaveAssets(); //manual load var fromDisk = AssetDatabase.LoadAssetAtPath(languageListPath, typeof(LanguageListSO)) as LanguageListSO; Assert.NotNull(fromDisk); Assert.NotNull(fromDisk.list); Assert.NotNull(fromDisk.list.languages); Assert.Greater(fromDisk.list.languages.Count, 0); Debug.Log("newlist:" + JsonWriter.Serialize(newList)); }
private WebServiceReturnStatus doCall(WebServiceParameters call) { IWebService req = new SyncronousEditorWebRequest(); try { call.getParameters.Add("token", _token); WebServiceReturnStatus result = req.request(call); return result; } catch(HttpErrorCode code) { Debug.Log(code.code + " http error"); throw; } }
private LanguageList getLanguageList() { var language = new RequestAllLanguages(); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus status = requester.request(language); LanguageList list = language.Parse(status.text); Assert.NotNull(list); Assert.IsTrue(list.languages.Count > 0); return list; }
//[MenuItem("Transfluent/test full loop english content")] public static void getTestSaveEnglishContent() { var list = ResourceLoadFacade.getLanguageList(); GameTranslationSet source = GameTranslationGetter.GetTranslaitonSetFromLanguageCode("en-us"); var sender = new FileBasedSend(); var contents = sender.SendFileContents(source.getGroup().getDictionaryCopy(), list.getLangaugeByCode("en-us"), "", ""); Debug.Log("Contents :" + contents); TransfluentEditorWindowMediator mediator = new TransfluentEditorWindowMediator(); mediator.doAuth(); string authToken = mediator.getCurrentAuthToken(); string fileIdentifier = "testfile"; var sourceLang = list.getLangaugeByCode("en-us"); var saveCall = new FileBasedSaveCall(fileIdentifier, sourceLang.id, authToken, contents); var caller = new SyncronousEditorWebRequest(); var returnStatus = caller.request(saveCall); Debug.Log("saved file return status:"); Debug.Log(JsonWriter.Serialize(returnStatus)); Debug.Log("auth token:" + authToken); var translateRequest = new FileTranslate("", new int[] { 3, 4 }, OrderTranslation.TranslationQuality.NATIVE_SPEAKER, fileIdentifier, sourceLang.id, authToken); var translateReturn = caller.request(translateRequest); Debug.Log("translate request file:"); Debug.Log(JsonWriter.Serialize(translateReturn)); var translateResultRequest = new FileBasedRead(fileIdentifier, sourceLang.id, authToken); var translateResultReturn = caller.request(translateResultRequest); Debug.Log("translate resulting file:"); Debug.Log(JsonWriter.Serialize(translateResultReturn)); }
public void testTranslation() { var translateRequest = new OrderTranslation(englishLanguage.id, new[] { backwardsLanguage.id }, new[] { TRANSLATION_KEY }); OrderTranslation.TextsTranslateResult translationResult = translateRequest.Parse(justCall(translateRequest)); var requester = new SyncronousEditorWebRequest(); WebServiceReturnStatus result = requester.request(translateRequest); Debug.Log("Full result from test translation:" + JsonWriter.Serialize(result.text)); Assert.IsTrue(translationResult.word_count > 0); }