public void InsertAndRemoveMarker() { var allParaOccurrences = MakeAnalysesUsedN(1); var row0 = MakeRow("1a"); MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[0]); var marker = Cache.LangProject.DiscourseDataOA.ChartMarkersOA.PossibilitiesOS[1].SubPossibilitiesOS[0]; var row0col1 = MakeLocObj(row0, 1); EndSetupTask(); // SUT has its own UOW using (var menuItem = new RowColPossibilityMenuItem(row0col1, marker.Hvo)) { // SUT m_logic.AddOrRemoveMarker(menuItem); VerifyInsertMarker(marker); // Now test Undo Assert.IsTrue(Cache.ActionHandlerAccessor.CanUndo()); Cache.ActionHandlerAccessor.Undo(); VerifyRemovedMarker(allParaOccurrences); // And now Redo Assert.IsTrue(Cache.ActionHandlerAccessor.CanRedo()); Cache.ActionHandlerAccessor.Redo(); VerifyInsertMarker(marker); // Now make sure we can delete it again. using (var item = new RowColPossibilityMenuItem(row0col1, marker.Hvo)) { item.Checked = true; m_logic.AddOrRemoveMarker(item); VerifyRemovedMarker(allParaOccurrences); } // Now test Undo using (new NotifyChangeSpy(m_mockRibbon.Decorator)) { Assert.IsTrue(Cache.ActionHandlerAccessor.CanUndo()); Cache.ActionHandlerAccessor.Undo(); VerifyInsertMarker(marker); } // And now Redo using (new NotifyChangeSpy(m_mockRibbon.Decorator)) { Assert.IsTrue(Cache.ActionHandlerAccessor.CanRedo()); Cache.ActionHandlerAccessor.Redo(); VerifyRemovedMarker(allParaOccurrences); } } }
public void AddNonContentToMissingMarker() { const int icol = 1; var row0 = m_helper.MakeRow1a(); var cell = MakeLocObj(row0, icol); var missMarker = m_helper.MakeMissingMarker(row0, icol); var possItem = m_helper.GetAMarker(); using (var rcpmi = new RowColPossibilityMenuItem(cell, possItem.Hvo)) { rcpmi.Checked = false; var nextHvo = missMarker.Hvo + 1; EndSetupTask(); // SUT has its own UOW // SUT m_logic.AddOrRemoveMarker(rcpmi); // Verify var newTag = VerifyCreatedCellPart(nextHvo, "Should have made a marker CellPart") as IConstChartTag; // Should not have removed missing marker in row and added other marker. VerifyRowContents(0, new IConstituentChartCellPart[] { missMarker, newTag }); VerifyTag(0, 1, m_allColumns[icol], possItem); } }
public void AddNonContentToMissingMarker() { const int icol = 1; CmIndirectAnnotation row0 = m_helper.MakeRow1a(); ChartLocation cell = MakeLocObj(row0, icol); CmIndirectAnnotation missMarker = m_helper.MakeColumnAnnotation(icol, new int[0], row0); int hvoPossItem = m_helper.GetAMarker().Hvo; RowColPossibilityMenuItem rcpmi = new RowColPossibilityMenuItem(cell, hvoPossItem); rcpmi.Checked = false; StartCheckingDataAccess(); int newId = m_sdaChecker.GetNewObjectId(); m_sdaChecker.ExpectCreateObjectInCollection(Cache.LangProject.Hvo, kflidAnnotations, 1, "Should have created possibility marker "+newId+"."); m_sdaChecker.ExpectVector(row0.Hvo, kflidAppliesTo, new int[] { missMarker.Hvo, newId }, "Should not have removed missing marker in row and added other marker."); m_sdaChecker.ExpectAtomic(newId, kflidInstanceOf, m_logic.AllMyColumns[icol], "Should have put new marker in column "+icol+"."); m_sdaChecker.ExpectVector(newId, kflidAppliesTo, new int[0], "The new marker shouldn't refer to any wfic."); // SUT m_logic.AddOrRemoveMarker(rcpmi); m_sdaChecker.VerifyExpectedChanges(); (Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText( ConstituentChartLogic.FTO_UndoAddMarker, ConstituentChartLogic.FTO_RedoAddMarker, "Should be undo add marker."); }
public void InsertAndRemoveMarker() { int[] allParaWfics = MakeAnnotationsUsedN(1); CmIndirectAnnotation row0 = MakeRow("1a"); CmIndirectAnnotation cca0_1 = MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0); ICmPossibility marker = Cache.LangProject.DiscourseDataOA.ChartMarkersOA.PossibilitiesOS[1].SubPossibilitiesOS[0]; ChartLocation row0col1 = new ChartLocation(1, row0); using (NotifyChangeSpy spy = new NotifyChangeSpy(Cache.MainCacheAccessor)) { m_logic.AddOrRemoveMarker(new RowColPossibilityMenuItem(row0col1, marker.Hvo)); VerifyInsertMarker(spy, row0, marker); spy.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 1, 1, 0); } // Now test Undo using (NotifyChangeSpy undoSpy = new NotifyChangeSpy(Cache.MainCacheAccessor)) { Assert.IsTrue(Cache.CanUndo); Cache.Undo(); VerifyRemovedMarker(allParaWfics); // Verify various PropChanged calls. undoSpy.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 1, 2); } // And now Redo using (NotifyChangeSpy redoSpy = new NotifyChangeSpy(Cache.MainCacheAccessor)) { Assert.IsTrue(Cache.CanRedo); Cache.Redo(); VerifyInsertMarker(redoSpy, row0, marker); redoSpy.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 2, 1); } // Now make sure we can delete it again. using (NotifyChangeSpy delSpy = new NotifyChangeSpy(Cache.MainCacheAccessor)) { RowColPossibilityMenuItem item = new RowColPossibilityMenuItem(row0col1, marker.Hvo); item.Checked = true; m_logic.AddOrRemoveMarker(item); VerifyRemovedMarker(allParaWfics); delSpy.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 1, 0, 1); } // Now test Undo using (NotifyChangeSpy undoSpy2 = new NotifyChangeSpy(Cache.MainCacheAccessor)) { Assert.IsTrue(Cache.CanUndo); Cache.Undo(); VerifyInsertMarker(undoSpy2, row0, marker); undoSpy2.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 2, 1); } // And now Redo using (NotifyChangeSpy redoSpy2 = new NotifyChangeSpy(Cache.MainCacheAccessor)) { Assert.IsTrue(Cache.CanRedo); Cache.Redo(); VerifyRemovedMarker(allParaWfics); // Verify various PropChanged calls. redoSpy2.AssertHasNotification(row0.Hvo, (int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 1, 2); } }