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 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 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 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); } } }