public async Task CREATE_NEW() { TranslationEdit newTranslationEdit = null; var isAsyncComplete = false; var hasError = false; EnqueueConditional(() => isAsyncComplete); await Setup(); try { newTranslationEdit = await TranslationEdit.NewTranslationEditAsync(); } catch { hasError = true; } finally { EnqueueCallback( () => Assert.IsFalse(hasError), () => Assert.IsNotNull(newTranslationEdit), //KEEP THIS LAST IN THE CALLBACKS () => Teardown() ); EnqueueTestComplete(); isAsyncComplete = true; } }
public void CREATE_NEW() { var isCreated = false; BlankTranslationCreator retriever = null; TranslationEdit blankTranslation = null; BlankTranslationCreator.CreateNew((s, r) => { if (r.Error != null) { throw r.Error; } retriever = r.Object; blankTranslation = retriever.Translation; isCreated = true; }); EnqueueConditional(() => isCreated); EnqueueCallback( () => { Assert.IsNotNull(retriever); }, () => { Assert.IsNotNull(blankTranslation); }, () => { Assert.IsNotNull(blankTranslation.Phrases); }, () => { Assert.IsTrue(blankTranslation.Phrases.Count == 2); }, () => { Assert.IsNotNull(blankTranslation.Phrases[0]); }, () => { Assert.IsNotNull(blankTranslation.Phrases[1]); }, () => { Assert.IsNotNull(blankTranslation.Phrases[0].Language); }, () => { Assert.IsNotNull(blankTranslation.Phrases[1].Language); } //() => { Assert.IsNull(newError); } ); EnqueueTestComplete(); }
/// <summary> /// Extracts the phrase (if found) in the given language. /// </summary> /// <param name="translation"></param> /// <param name="languageText"></param> /// <returns>If found, returns phrase in given language. Otherwise, returns null.</returns> public static PhraseEdit ExtractPhrase(TranslationEdit translation, string languageText) { var results = (from phrase in translation.Phrases where phrase.Language.Text == languageText select phrase).FirstOrDefault(); return results; }
//Records edits used in translation operation void recordEdits(Transform transformEditing) { //Record edits for translation TranslationEdit translationEdit = new TranslationEdit(transformEditing, initTransformEditingEditVector, transformEditing.position); TranslationEdit transformToolEdit = new TranslationEdit(transformTool.transform, initTransformToolEditVector, transformTool.transform.position); //Create compound edit to store transformEditing and transformTool translations CompoundEdit compoundEdit = new CompoundEdit(); compoundEdit.addEdit(translationEdit); compoundEdit.addEdit(transformToolEdit); editTracker.trackEdit(compoundEdit); //Start tracking edit in edit tracker }
//Records edits used in scaling operation void recordEdits(Transform transformEditing) { //Record edits for scaling ScaleEdit scaleEdit = new ScaleEdit(transformEditing, initTransformEditingScale, transformEditing.localScale); TranslationEdit posOffsetEdit = new TranslationEdit(transformEditing, initTransformEditingWorldPos, transformEditing.position); //Create compound edit to store transformEditing and transformTool translations CompoundEdit compoundEdit = new CompoundEdit(); compoundEdit.addEdit(scaleEdit); compoundEdit.addEdit(posOffsetEdit); editTracker.trackEdit(compoundEdit); //Start tracking edit in edit tracker }
public async Task GET() { Guid testId = Guid.Empty; TranslationEdit translationEdit = null; TranslationList allTranslations = null; var isAsyncComplete = false; var hasError = false; EnqueueConditional(() => isAsyncComplete); await Setup(); try { allTranslations = await TranslationList.GetAllAsync(); testId = allTranslations.First().Id; translationEdit = await TranslationEdit.GetTranslationEditAsync(testId); } catch { hasError = true; } finally { EnqueueCallback( () => Assert.IsFalse(hasError), () => Assert.IsNotNull(translationEdit), () => Assert.IsTrue(translationEdit.Phrases.Count >= 2), () => Assert.AreEqual(testId, translationEdit.Id), //KEEP THIS LAST IN THE CALLBACKS () => Teardown() ); EnqueueTestComplete(); isAsyncComplete = true; } }
public override void SetModel(TranslationEdit model) { base.SetModel(model); PhrasesViewModel.ModelList = model.Phrases; }
public void SetQuestionAnswer(TranslationEdit translation, string questionLanguageText) { }
public async Task TRANSLATION_CREATOR_NEW() { TranslationEdit newTranslationEdit = null; TranslationEdit savedTranslationEdit = null; TranslationEdit confirmedSaveTranslationEdit = null; Business.TranslationCreator creator = null; string phraseAText = "Test Phrase A Text. This is phrase A in English."; string phraseBText = "Test Phrase BBBB Text. This is phrase B in Spanish."; //PhraseEdit phraseA = null; //PhraseEdit phraseB = null; var isAsyncComplete = false; var hasError = false; EnqueueConditional(() => isAsyncComplete); await Setup(); try { ////CREATE THE TWO PHRASES //phraseA = await PhraseEdit.NewPhraseEditAsync(_ServerEnglishLang.Text); //phraseA.Text = phraseAText; //phraseA = await phraseA.SaveAsync(); //phraseB = await PhraseEdit.NewPhraseEditAsync(_ServerSpanishLang.Text); //phraseB.Text = phraseBText; //phraseB = await phraseB.SaveAsync(); //AT THIS POINT, WE HAVE TWO PHRASES THAT WOULD BE EQUIVALENT PHRASES (A TRANSLATION). //NEW //var criteria = new Business.Criteria.ListOfPhrasesCriteria(phraseA, phraseB); //var creator = await Business.TranslationCreator.CreateNewAsync(criteria); var A = new Tuple <string, string>(); A.Item1 = phraseAText; A.Item2 = _ServerEnglishLang.Text; var B = new Tuple <string, string>(); B.Item1 = phraseBText; B.Item2 = _ServerSpanishLang.Text; var criteria = new Business.Criteria.PhraseTextLanguageTextPairsCriteria(A, B); creator = await Business.TranslationCreator.CreateNewAsync(criteria); newTranslationEdit = creator.Translation; #region old //Business.TranslationCreator.CreateNewAsync( // //EDIT // newTranslationEdit.Phrases.AddedNew += (s5, r5) => // { // if (phraseA == null) // { // phraseA = r5.NewObject; // phraseA.Id = Guid.NewGuid(); // phraseA.Text = phraseAText; // phraseA.LanguageId = SeedData.Ton.EnglishId; // } // else // { // phraseB = r5.NewObject; // phraseB.Id = Guid.NewGuid(); // phraseB.Text = phraseBText; // phraseB.LanguageId = SeedData.Ton.SpanishId; // } // }; //newTranslationEdit.Phrases.AddNew(); //newTranslationEdit.Phrases.AddNew(); #endregion //SAVE savedTranslationEdit = await newTranslationEdit.SaveAsync(); //GET (CONFIRM SAVE) confirmedSaveTranslationEdit = await TranslationEdit.GetTranslationEditAsync(savedTranslationEdit.Id); } catch { hasError = true; } finally { EnqueueCallback( () => Assert.IsFalse(hasError), () => Assert.IsNotNull(newTranslationEdit), () => Assert.IsNotNull(savedTranslationEdit), () => Assert.IsNotNull(confirmedSaveTranslationEdit), () => Assert.IsTrue(confirmedSaveTranslationEdit.Phrases.Count >= 2), () => Assert.AreEqual(savedTranslationEdit.Id, confirmedSaveTranslationEdit.Id), () => Assert.AreEqual(savedTranslationEdit.Phrases[0].Text, phraseAText), () => Assert.AreEqual(savedTranslationEdit.Phrases[1].Text, phraseBText), //KEEP THIS LAST IN THE CALLBACKS () => Teardown() ); EnqueueTestComplete(); isAsyncComplete = true; } }