public void Test_Common() { TestUtils.InitGEDCOMProviderTest(); // required for testing, otherwise the engine will require saving // the database (requires path of files for the archive and storage) GlobalOptions.Instance.AllowMediaStoreReferences = true; var appHost = (WFAppHost)AppHost.Instance; Assert.IsNotNull(appHost.AppContext); appHost.BaseClosed(null); appHost.CloseWindow(null); appHost.SaveWinMRU(null); // // at complex tests, first form hasn't focus ((Form)AppHost.Instance.RunningForms[0]).Show(); // FIXME fMainWin = (Form)AppHost.Instance.GetActiveWindow(); // Stage 1: call to AboutDlg, closing in AboutDlg_Handler ExpectModal("AboutDlg", "AboutDlg_Handler"); //ModalFormHandler = AboutDlgTests.AboutDlg_Handler; ClickToolStripMenuItem("miAbout", fMainWin); // Stage 2.1: GetCurrentFile() IBaseWindow curBase = AppHost.Instance.GetCurrentFile(); Assert.IsNotNull(curBase, "Stage 2.1"); Assert.AreEqual(fMainWin, curBase); // Stage 2.2: create an empty base //ClickToolStripButton("tbFileNew", fBaseSDI); // Stage 2.3: GetCurrentFile() fCurBase = AppHost.Instance.GetCurrentFile(); Assert.IsNotNull(fCurBase, "Stage 2.3"); // Stage 2.4: fill context for sample data TestUtils.FillContext(fCurBase.Context); fCurBase.UpdateSettings(); // Stage 2.5: select first individual record in base fCurBase.SelectRecordByXRef("I1"); Assert.AreEqual("I1", fCurBase.GetSelectedPerson().XRef); // Stage 3: call to FilePropertiesDlg ModalFormHandler = Dialog_Cancel_Handler; ClickToolStripMenuItem("miFileProperties", fMainWin); SetModalFormHandler(this, FilePropertiesDlgTests.FilePropertiesDlg_btnAccept_Handler); ClickToolStripMenuItem("miFileProperties", fMainWin); // Stage 4: call to OptionsDlg ModalFormHandler = Dialog_Cancel_Handler; ClickToolStripMenuItem("miOptions", fMainWin); ModalFormHandler = OptionsDlgTests.OptionsDlg_btnAccept_Handler; ClickToolStripMenuItem("miOptions", fMainWin); // Stage 5: internals of BaseWin BaseWin_Tests(fCurBase, "Stage 5"); // Stage 6 ModalFormHandler = DayTipsDlgTests.CloseModalHandler; AppHost.Instance.ShowTips(); // don't show dialog because BirthDays is empty AppHost.Instance.AddMRU("test.ged"); fMainWin.Activate(); Assert.AreEqual("Unknown", AppHost.Instance.GetCurrentFileName(), "check AppHost.Instance.GetCurrentFileName()"); Assert.Throws(typeof(ArgumentNullException), () => { AppHost.Instance.RequestGeoCoords(null, null); }); Assert.Throws(typeof(ArgumentNullException), () => { AppHost.Instance.RequestGeoCoords("Moscow", null); }); // IHost tests //IHost host = fMainWin; // FIXME: !!! IHost host = AppHost.Instance; GlobalOptions.Instance.LastDir = ""; string ufPath = host.GetUserFilesPath(""); Assert.AreEqual(GKUtils.GetHomePath(), ufPath); Assert.IsFalse(string.IsNullOrEmpty(ufPath)); IBaseWindow baseWin = host.FindBase("Unknown"); Assert.IsNotNull(baseWin); ModalFormHandler = MessageBox_OkHandler; AppHost.StdDialogs.ShowWarning("test warn"); ILangMan langMan = host.CreateLangMan(null); Assert.IsNull(langMan); host.WidgetShow(null); host.WidgetClose(null); Assert.IsFalse(host.IsWidgetActive(null)); host.EnableWindow(null, false); host.BaseRenamed(null, "", ""); ClickToolStripButton("tbNext", fMainWin); ClickToolStripButton("tbPrev", fMainWin); // Stage 7: call to QuickFind ((BaseWinSDI)fCurBase).ShowRecordsTab(GDMRecordType.rtIndividual); QuickSearchDlgTests.QuickSearch_Test(fMainWin); // Stage 21: call to TreeToolsWin SetModalFormHandler(this, TreeToolsWinTests.TreeCompareDlg_Handler); ClickToolStripMenuItem("miTreeCompare", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.TreeMergeDlg_Handler); ClickToolStripMenuItem("miTreeMerge", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.TreeSplitDlg_Handler); ClickToolStripMenuItem("miTreeSplit", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.RecMergeDlg_Handler); ClickToolStripMenuItem("miRecMerge", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.FamilyGroupsDlg_Handler); ClickToolStripMenuItem("miFamilyGroups", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.TreeCheckDlg_Handler); ClickToolStripMenuItem("miTreeCheck", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.PatSearchDlg_Handler); ClickToolStripMenuItem("miPatSearch", fMainWin); SetModalFormHandler(this, TreeToolsWinTests.PlacesManagerDlg_Handler); ClickToolStripMenuItem("miPlacesManager", fMainWin); // Stage 22-24: call to exports Exporter.TEST_MODE = true; try { ModalFormHandler = SaveFilePDF_Handler; ClickToolStripMenuItem("miExportToFamilyBook", fMainWin); } finally { TestUtils.RemoveTestFile(TestUtils.GetTempFilePath("test.pdf")); } try { ModalFormHandler = SaveFileXLS_Handler; ClickToolStripMenuItem("miExportToExcelFile", fMainWin); } finally { TestUtils.RemoveTestFile(TestUtils.GetTempFilePath("test.xls")); } GeneratePedigree_Tests("Stage 24"); // FIXME: fatal loop //ModalFormHandler = SaveFilePDF_Handler; //ClickToolStripMenuItem("miExportToTreesAlbum", fMainWin); // Stage 25: call to CircleChartWin (required the base, selected person) fCurBase.SelectRecordByXRef("I3"); Assert.AreEqual("I3", fCurBase.GetSelectedPerson().XRef, "Stage 25.0"); ClickToolStripMenuItem("miAncestorsCircle", fMainWin); CircleChartWinTests.CircleChartWin_Tests(this, GetActiveForm("CircleChartWin"), "Stage 25"); // Stage 26: call to CircleChartWin (required the base, selected person) fCurBase.SelectRecordByXRef("I1"); Assert.AreEqual("I1", fCurBase.GetSelectedPerson().XRef, "Stage 26.0"); ClickToolStripMenuItem("miDescendantsCircle", fMainWin); CircleChartWinTests.CircleChartWin_Tests(this, GetActiveForm("CircleChartWin"), "Stage 26"); // Stage 27: call to TreeChartWin (required the base, selected person) fCurBase.SelectRecordByXRef("I3"); Assert.AreEqual("I3", fCurBase.GetSelectedPerson().XRef, "Stage 27.0"); ClickToolStripButton("tbTreeAncestors", fMainWin); TreeChartWinTests.TreeChartWin_Tests(this, fMainWin, GetActiveForm("TreeChartWin"), TreeChartKind.ckAncestors, "Stage 27", "I3"); // Stage 28: call to TreeChartWin (required the base, selected person) fCurBase.SelectRecordByXRef("I1"); Assert.AreEqual("I1", fCurBase.GetSelectedPerson().XRef, "Stage 28.0"); ClickToolStripButton("tbTreeDescendants", fMainWin); TreeChartWinTests.TreeChartWin_Tests(this, fMainWin, GetActiveForm("TreeChartWin"), TreeChartKind.ckDescendants, "Stage 28", "I1"); // Stage 29: call to TreeChartWin (required the base, selected person) ClickToolStripButton("tbTreeBoth", fMainWin); TreeChartWinTests.TreeChartWin_Tests(this, fMainWin, GetActiveForm("TreeChartWin"), TreeChartKind.ckBoth, "Stage 29", "I1"); // Stage 30: call to StatsWin (required the base) ClickToolStripButton("tbStats", fMainWin); StatisticsWinTests.StatsWin_Handler(this, GetActiveForm("StatisticsWin"), "Stage 30"); // Stage 31: call to SlideshowWin (required the base) ClickToolStripMenuItem("miSlideshow", fMainWin); SlideshowWinTests.SlideshowWin_Handler(this, GetActiveForm("SlideshowWin"), "Stage 31"); // Stage 32: call to ScriptEditWin (required the base) SetModalFormHandler(this, ScriptEditWinTests.ScriptEditWin_Handler); ClickToolStripMenuItem("miScripts", fMainWin); //Assert.IsTrue((Form)AppHost.Instance.GetActiveWindow(), "Stage 32"); // Stage 33: call to OrganizerWin ModalFormHandler = OrganizerWinTests.OrganizerWin_Handler; ClickToolStripMenuItem("miOrganizer", fMainWin); // Stage 34: call to RelationshipCalculatorDlg ModalFormHandler = RelationshipCalculatorDlgTests.RelationshipCalculatorDlg_Handler; ClickToolStripMenuItem("miRelationshipCalculator", fMainWin); // Stage 35: call to MapsViewerWin (required the base) ClickToolStripMenuItem("miMap", fMainWin); MapsViewerWinTests.MapsViewerWin_Handler(this, GetActiveForm("MapsViewerWin"), "Stage 35"); // Stage 36 ModalFormHandler = MessageBox_OkHandler; fCurBase.DuplicateRecord(); // Stage 47: close Base ModalFormHandler = MessageBox_CancelHandler; ClickToolStripMenuItem("miFileLoad", fMainWin); // Stage 48: close Base ModalFormHandler = MessageBox_CancelHandler; ClickToolStripMenuItem("miFileSaveAs", fMainWin); // Stage 49: close Base ModalFormHandler = MessageBox_CancelHandler; ClickToolStripMenuItem("miFileSave", fMainWin); // Stage 50: close Base Assert.IsTrue(fCurBase.Context.Modified); ModalFormHandler = MessageBox_CancelHandler; ClickToolStripMenuItem("miFileClose", fMainWin); // Stage 51: call to LanguageSelectDlg ModalFormHandler = LanguageSelectDlgTests.LanguageSelectDlg_Accept_Handler; AppHost.Instance.LoadLanguage(0); // Stage 52: exit //ClickToolStripMenuItem("miExit", fBaseSDI); // Other ModalFormHandler = MessageBox_OkHandler; AppHost.StdDialogs.ShowMessage("test msg"); ModalFormHandler = MessageBox_OkHandler; AppHost.StdDialogs.ShowError("test error msg"); }