Esempio n. 1
0
        /// <summary>
        /// non-undoable task
        /// </summary>
        private void DoSetupFixture()
        {
            // setup default vernacular ws.
            CoreWritingSystemDefinition wsXkal = Cache.ServiceLocator.WritingSystemManager.Set("qaa-x-kal");

            wsXkal.DefaultFont = new FontDefinition("Times New Roman");
            Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(wsXkal);
            Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Insert(0, wsXkal);
            var textFactory   = Cache.ServiceLocator.GetInstance <ITextFactory>();
            var stTextFactory = Cache.ServiceLocator.GetInstance <IStTextFactory>();

            m_text0 = textFactory.Create();
            //Cache.LangProject.TextsOC.Add(m_text0);
            m_stText0          = stTextFactory.Create();
            m_text0.ContentsOA = m_stText0;
            m_para0_0          = m_stText0.AddNewTextPara(null);
            m_para0_0.Contents = TsStringUtils.MakeString("Xxxhope xxxthis xxxwill xxxdo. xxxI xxxhope.", wsXkal.Handle);

            InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(m_stText0, false);
            // paragraph 0_0 simply has wordforms as analyses
            foreach (var occurence in SegmentServices.GetAnalysisOccurrences(m_para0_0))
            {
                if (occurence.HasWordform)
                {
                    m_analysis_para0_0.Add(new AnalysisTree(occurence.Analysis));
                }
            }
        }
Esempio n. 2
0
        public void ApproveAndStayPut_NewWordGloss()
        {
            var occurrences = SegmentServices.GetAnalysisOccurrences(m_para0_0).ToList();

            m_interlinDoc.SelectOccurrence(occurrences[0]);
            // create a new analysis.
            var initialAnalysisTree = m_focusBox.InitialAnalysis;

            m_focusBox.DoDuringUnitOfWork = () =>
                                            WordAnalysisOrGlossServices.CreateNewAnalysisTreeGloss(initialAnalysisTree.Wordform);
            var undoRedoText = new MockUndoRedoText("Undo", "Redo");

            m_focusBox.ApproveAndStayPut(undoRedoText);

            // expect change to the first occurrence.
            Assert.AreEqual(m_focusBox.NewAnalysisTree.Gloss, occurrences[0].Analysis);
            // expect the focus box to still be on the first occurrence.
            Assert.AreEqual(occurrences[0], m_focusBox.SelectedOccurrence);

            // test undo.
            Assert.AreEqual(1, Cache.ActionHandlerAccessor.UndoableSequenceCount);
            Cache.ActionHandlerAccessor.Undo();
            Assert.AreEqual(initialAnalysisTree.Analysis, occurrences[0].Analysis);
            // expect the focus box to still be on the first occurrence.
            Assert.AreEqual(occurrences[0], m_focusBox.SelectedOccurrence);
        }
Esempio n. 3
0
        public void ApproveAndMoveNext_NoChange()
        {
            var occurrences = SegmentServices.GetAnalysisOccurrences(m_para0_0).ToList();

            m_interlinDoc.SelectOccurrence(occurrences[0]);
            var initialAnalysisTree = m_focusBox.InitialAnalysis;
            var undoRedoText        = new MockUndoRedoText("Undo", "Redo");

            m_focusBox.ApproveAndMoveNext(undoRedoText);

            // expect no change to the first occurrence.
            Assert.AreEqual(initialAnalysisTree.Analysis, occurrences[0].Analysis);
            // expect the focus box to be on the next occurrence.
            Assert.AreEqual(occurrences[1], m_focusBox.SelectedOccurrence);

            // nothing to undo.
            Assert.AreEqual(0, Cache.ActionHandlerAccessor.UndoableSequenceCount);
        }
Esempio n. 4
0
        public void ApproveAndStayPut_NoChange()
        {
            var ocurrences = SegmentServices.GetAnalysisOccurrences(m_para0_0).ToList();

            m_interlinDoc.SelectOccurrence(ocurrences[0]);
            var initialAnalysisObj = m_focusBox.InitialAnalysis.Analysis;

            // approve same wordform. Should not result in change during approve.
            m_focusBox.NewAnalysisTree.Analysis = ocurrences[0].Analysis;
            var undoRedoText = new MockUndoRedoText("Undo", "Redo");

            m_focusBox.ApproveAndStayPut(undoRedoText);

            // expect no change to the first occurrence.
            Assert.AreEqual(initialAnalysisObj, ocurrences[0].Analysis);
            // expect the focus box to still be on the first occurrence.
            Assert.AreEqual(ocurrences[0], m_focusBox.SelectedOccurrence);

            // nothing to undo.
            Assert.AreEqual(0, Cache.ActionHandlerAccessor.UndoableSequenceCount);
        }