public void DeleteOnlyBook() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the only book from the first archive; // we expect the archive itself to also be deleted TreeNode archiveNode = null; for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { archiveNode = tree.Nodes[i]; break; } } Assert.AreEqual(1, archiveNode.Nodes.Count); //only one book exists in this archive TreeNode bookNode = archiveNode.Nodes[0]; tree.SelectedNode = bookNode; dlg.SimulateDelete(); // check the counts of archives and books in the archives Assert.AreEqual(2, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) { Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); } else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); } else { Assert.Fail("Seems we deleted the wrong archive"); } } // check the count of archives in the DB Assert.AreEqual(2, m_scr.ArchivedDraftsOC.Count); // make sure the correct archive was deleted in the DB. foreach (IScrDraft archive in m_scr.ArchivedDraftsOC) { Assert.IsTrue(archive.Description != "My Archive 0", "\"My Archive 0\" should have been deleted."); } } }
public void DeleteSavedVersion() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the archive which has two books for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) { tree.SelectedNode = tree.Nodes[i]; } } dlg.SimulateDelete(); // check the node counts Assert.AreEqual(2, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); } else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); } else { Assert.Fail("Seems we deleted the wrong archive"); } } // Check the count of archives in the DB Assert.AreEqual(2, m_scr.ArchivedDraftsOC.Count); // Make sure the correct archive was deleted in the DB. foreach (IScrDraft archive in m_scr.ArchivedDraftsOC) { Assert.IsTrue(archive.Description != "My Archive 1", "\"My Archive 1\" should have been deleted."); } } }
public void FillTreeView() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { // verify the tree view contents TreeView tree = dlg.ArchiveTree; // Check the node counts and the archive names and book names Assert.AreEqual(3, tree.Nodes.Count, "The count of root nodes in the tree is incorrect"); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 1; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) { Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 2; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 3; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else { Assert.Fail("Seems we have an extra archive"); } } } }
public void DeleteAllItems() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; while (tree.Nodes.Count != 0) { tree.SelectedNode = tree.Nodes[0]; dlg.SimulateDelete(); } // Verify that the buttons are disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); Assert.IsFalse(dlg.DeleteBtn.Enabled, "The delete button should be disabled"); dlg.Close(); } }
public void DeleteAllItems() { DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(m_cache); TreeView tree = dlg.ArchiveTree; while (tree.Nodes.Count != 0) { tree.SelectedNode = tree.Nodes[0]; dlg.SimulateDelete(); } // Verify that the buttons are disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); Assert.IsFalse(dlg.DeleteBtn.Enabled, "The delete button should be disabled"); dlg.Close(); // Also check to see if the dialog comes up with the buttons disabled when there // are no archives dlg = new DummySavedVersionsDialog(m_cache); // Verify that the buttons are disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); Assert.IsFalse(dlg.DeleteBtn.Enabled, "The delete button should be disabled"); }
public void DeleteAllItems_NoArchive() { m_scr.ArchivedDraftsOC.Clear(); using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { // Verify that the buttons are disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); Assert.IsFalse(dlg.DeleteBtn.Enabled, "The delete button should be disabled"); } }
public void DisableCompareBtn() { // Add Revelation, archive it and then remove it. IStText title; Assert.IsNull(m_scr.FindBook(66), "Revelation should not be in the database. Restore the clean version of TestLangProj."); IScrBook revelation = Cache.ServiceLocator.GetInstance<IScrBookFactory>().Create(66, out title); ITsPropsFactory propFact = TsPropsFactoryClass.Create(); ITsTextProps ttp = propFact.MakeProps(ScrStyleNames.NormalParagraph, Cache.DefaultVernWs, 0); Cache.ServiceLocator.GetInstance<IScrSectionFactory>().CreateScrSection(revelation, 0, "Text for section", ttp, false); AddArchive("Revelation Archive", new List<IScrBook>(new IScrBook[] { revelation })); m_scr.ScriptureBooksOS.Remove(revelation); using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Select the archive node that was just added. tree.SelectedNode = tree.Nodes[0]; dlg.SimulateSelectEvent(); // Check to make sure the Compare to Current Version button is disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); TreeNode revNode = null; TreeNode phmNode = null; foreach (TreeNode node in tree.Nodes) { if (node.Nodes.Count > 0 && node.Nodes[0].Tag is IScrBook) { if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 66) revNode = node.Nodes[0]; if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 57) phmNode = node.Nodes[0]; } } Assert.IsNotNull(revNode, "there should be an archive where the first book is Revelation"); Assert.IsNotNull(phmNode, "there should be an archive where the first book is Philemon"); // Select a book node for Revelation. tree.SelectedNode = revNode; dlg.SimulateSelectEvent(); // Check to make sure the Diff button is still disabled if we select Revelation // after it is removed from the DB. Assert.IsTrue(tree.SelectedNode.Tag is IScrBook); var bookId = ((IScrBook)tree.SelectedNode.Tag).CanonicalNum; Assert.AreEqual(66, bookId); Assert.IsNull(m_scr.FindBook(bookId)); Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should still be disabled."); // However, the diff button should be enabled if we select Philemon in the second archive // since it is in our database. tree.SelectedNode = phmNode; // selecting Philemon dlg.SimulateSelectEvent(); Assert.IsTrue(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be enabled when Philemon is selected."); } }
public void DeleteSavedVersion() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the archive which has two books for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) tree.SelectedNode = tree.Nodes[i]; } dlg.SimulateDelete(); // check the node counts Assert.AreEqual(2, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); else Assert.Fail("Seems we deleted the wrong archive"); } // Check the count of archives in the DB Assert.AreEqual(2, m_scr.ArchivedDraftsOC.Count); // Make sure the correct archive was deleted in the DB. foreach (IScrDraft archive in m_scr.ArchivedDraftsOC) Assert.IsTrue(archive.Description != "My Archive 1", "\"My Archive 1\" should have been deleted."); } }
public void DeleteOnlyBook() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the only book from the first archive; // we expect the archive itself to also be deleted TreeNode archiveNode = null; for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { archiveNode = tree.Nodes[i]; break; } } Assert.AreEqual(1, archiveNode.Nodes.Count); //only one book exists in this archive TreeNode bookNode = archiveNode.Nodes[0]; tree.SelectedNode = bookNode; dlg.SimulateDelete(); // check the counts of archives and books in the archives Assert.AreEqual(2, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); else Assert.Fail("Seems we deleted the wrong archive"); } // check the count of archives in the DB Assert.AreEqual(2, m_scr.ArchivedDraftsOC.Count); // make sure the correct archive was deleted in the DB. foreach (IScrDraft archive in m_scr.ArchivedDraftsOC) Assert.IsTrue(archive.Description != "My Archive 0", "\"My Archive 0\" should have been deleted."); } }
public void DeleteBook() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the first book from the last archive (Philemon) TreeNode archiveNode = null; for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { archiveNode = tree.Nodes[i]; break; } } tree.SelectedNode = archiveNode.Nodes[0]; dlg.SimulateDelete(); // check the node counts Assert.AreEqual(3, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); else if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); else Assert.Fail("Seems we have an extra archive"); } // Check the remaining book names for the archive that was deleted from. for (int i = 0; i < 2; i++) { string bookLabel = archiveNode.Nodes[i].Text; Assert.AreEqual(m_bookScrRange[i + 1], bookLabel); } // Check the books in the database to make sure the database is correct. Assert.AreEqual(3, m_scr.ArchivedDraftsOC.Count); IScrDraft archive = (IScrDraft)archiveNode.Tag; Assert.AreEqual(2, archive.BooksOS.Count); List<int> cannonicalBookNums = new List<int>(new int[] { 59, 65 }); for (int iArchivedBook = 0; iArchivedBook < archive.BooksOS.Count; iArchivedBook++) { IScrBook book = archive.BooksOS[iArchivedBook]; Assert.AreEqual(cannonicalBookNums[iArchivedBook], book.CanonicalNum); Assert.AreEqual(m_bookNames[iArchivedBook + 1], book.BestUIName); } } }
public void FillTreeView() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { // verify the tree view contents TreeView tree = dlg.ArchiveTree; // Check the node counts and the archive names and book names Assert.AreEqual(3, tree.Nodes.Count, "The count of root nodes in the tree is incorrect"); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 1; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) { Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 2; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { Assert.AreEqual(3, tree.Nodes[i].Nodes.Count); for (int bookIndex = 0; bookIndex < 3; bookIndex++) { string bookLabel = tree.Nodes[i].Nodes[bookIndex].Text; Assert.AreEqual(m_bookScrRange[bookIndex], bookLabel, "The book label was incorrect in the tree"); } } else Assert.Fail("Seems we have an extra archive"); } } }
public void DisableCompareBtn() { // Add Revelation, archive it and then remove it. IStText title; Assert.IsNull(m_scr.FindBook(66), "Revelation should not be in the database. Restore the clean version of TestLangProj."); IScrBook revelation = Cache.ServiceLocator.GetInstance <IScrBookFactory>().Create(66, out title); ITsPropsFactory propFact = TsPropsFactoryClass.Create(); ITsTextProps ttp = propFact.MakeProps(ScrStyleNames.NormalParagraph, Cache.DefaultVernWs, 0); Cache.ServiceLocator.GetInstance <IScrSectionFactory>().CreateScrSection(revelation, 0, "Text for section", ttp, false); AddArchive("Revelation Archive", new List <IScrBook>(new IScrBook[] { revelation })); m_scr.ScriptureBooksOS.Remove(revelation); using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Select the archive node that was just added. tree.SelectedNode = tree.Nodes[0]; dlg.SimulateSelectEvent(); // Check to make sure the Compare to Current Version button is disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); TreeNode revNode = null; TreeNode phmNode = null; foreach (TreeNode node in tree.Nodes) { if (node.Nodes.Count > 0 && node.Nodes[0].Tag is IScrBook) { if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 66) { revNode = node.Nodes[0]; } if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 57) { phmNode = node.Nodes[0]; } } } Assert.IsNotNull(revNode, "there should be an archive where the first book is Revelation"); Assert.IsNotNull(phmNode, "there should be an archive where the first book is Philemon"); // Select a book node for Revelation. tree.SelectedNode = revNode; dlg.SimulateSelectEvent(); // Check to make sure the Diff button is still disabled if we select Revelation // after it is removed from the DB. Assert.IsTrue(tree.SelectedNode.Tag is IScrBook); var bookId = ((IScrBook)tree.SelectedNode.Tag).CanonicalNum; Assert.AreEqual(66, bookId); Assert.IsNull(m_scr.FindBook(bookId)); Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should still be disabled."); // However, the diff button should be enabled if we select Philemon in the second archive // since it is in our database. tree.SelectedNode = phmNode; // selecting Philemon dlg.SimulateSelectEvent(); Assert.IsTrue(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be enabled when Philemon is selected."); } }
public void DeleteBook() { using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache)) { TreeView tree = dlg.ArchiveTree; // Delete the first book from the last archive (Philemon) TreeNode archiveNode = null; for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { archiveNode = tree.Nodes[i]; break; } } tree.SelectedNode = archiveNode.Nodes[0]; dlg.SimulateDelete(); // check the node counts Assert.AreEqual(3, tree.Nodes.Count); for (int i = 0; i < tree.Nodes.Count; i++) { if (tree.Nodes[i].Text.IndexOf("My Archive 0") != -1) { Assert.AreEqual(1, tree.Nodes[i].Nodes.Count); } else if (tree.Nodes[i].Text.IndexOf("My Archive 1") != -1) { Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); } else if (tree.Nodes[i].Text.IndexOf("My Archive 2") != -1) { Assert.AreEqual(2, tree.Nodes[i].Nodes.Count); } else { Assert.Fail("Seems we have an extra archive"); } } // Check the remaining book names for the archive that was deleted from. for (int i = 0; i < 2; i++) { string bookLabel = archiveNode.Nodes[i].Text; Assert.AreEqual(m_bookScrRange[i + 1], bookLabel); } // Check the books in the database to make sure the database is correct. Assert.AreEqual(3, m_scr.ArchivedDraftsOC.Count); IScrDraft archive = (IScrDraft)archiveNode.Tag; Assert.AreEqual(2, archive.BooksOS.Count); List <int> cannonicalBookNums = new List <int>(new int[] { 59, 65 }); for (int iArchivedBook = 0; iArchivedBook < archive.BooksOS.Count; iArchivedBook++) { IScrBook book = archive.BooksOS[iArchivedBook]; Assert.AreEqual(cannonicalBookNums[iArchivedBook], book.CanonicalNum); Assert.AreEqual(m_bookNames[iArchivedBook + 1], book.BestUIName); } } }
public void DisableCompareBtn() { // Add Revelation, archive it and then remove it. int hvoTitle; Assert.IsNull(ScrBook.FindBookByID(m_cache, 66), "Revelation should not be in the database. Restore the clean version of TestLangProj."); IScrBook revelation = ScrBook.CreateNewScrBook(66, m_scr, out hvoTitle); ITsPropsFactory propFact = TsPropsFactoryClass.Create(); ITsTextProps ttp = propFact.MakeProps(ScrStyleNames.NormalParagraph, m_cache.DefaultVernWs, 0); ScrSection.CreateScrSection(revelation, 0, "Text for section", ttp, false); AddArchive("Revelation Archive", new List<int>(new int[] { revelation.Hvo })); m_scr.ScriptureBooksOS.Remove(m_scr.ScriptureBooksOS[3]); DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(m_cache); TreeView tree = dlg.ArchiveTree; // Select the archive node that was just added. tree.SelectedNode = tree.Nodes[0]; dlg.SimulateSelectEvent(); // Check to make sure the Compare to Current Version button is disabled Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled"); // Select a book node. tree.SelectedNode = tree.Nodes[0].Nodes[0]; dlg.SimulateSelectEvent(); // Check to make sure the Diff button is still disabled if we select Philemon // after it is removed from the DB. Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should still"); }