public void Test_SearchTreeFragments_MergeTree() { List <List <GDMRecord> > treeFragments; Assembly assembly = typeof(CoreTests).Assembly; using (var ctx1 = new BaseContext(null)) { IBaseWindow baseWin = new BaseWindowStub(ctx1); using (Stream stmGed1 = assembly.GetManifestResourceStream("GKTests.Resources.test1.ged")) { var gedcomProvider = new GEDCOMProvider(ctx1.Tree); gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1); } treeFragments = TreeTools.SearchTreeFragments(ctx1.Tree, null); Assert.AreEqual(2, treeFragments.Count); Assert.AreEqual(13, treeFragments[0].Count); Assert.AreEqual(1, treeFragments[1].Count); using (var ctx2 = new BaseContext(null)) { using (Stream stmGed2 = assembly.GetManifestResourceStream("GKTests.Resources.test2.ged")) { var gedcomProvider = new GEDCOMProvider(ctx2.Tree); gedcomProvider.LoadFromStreamExt(stmGed2, stmGed2); } treeFragments = TreeTools.SearchTreeFragments(ctx2.Tree, null); Assert.AreEqual(2, treeFragments.Count); Assert.AreEqual(15, treeFragments[0].Count); Assert.AreEqual(1, treeFragments[1].Count); TreeTools.MergeTree(ctx1.Tree, ctx2.Tree, null); treeFragments = TreeTools.SearchTreeFragments(ctx1.Tree, null); Assert.AreEqual(4, treeFragments.Count); Assert.AreEqual(13, treeFragments[0].Count); Assert.AreEqual(1, treeFragments[1].Count); Assert.AreEqual(15, treeFragments[2].Count); Assert.AreEqual(1, treeFragments[3].Count); GDMIndividualRecord iRec1 = ctx1.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; Assert.IsNotNull(iRec1); GDMIndividualRecord iRec2 = ctx1.Tree.XRefIndex_Find("I3") as GDMIndividualRecord; Assert.IsNotNull(iRec2); TreeTools.MergeRecord(baseWin, iRec1, iRec2, true); treeFragments = TreeTools.SearchTreeFragments(ctx1.Tree, null); Assert.AreEqual(3, treeFragments.Count); Assert.AreEqual(13, treeFragments[0].Count); Assert.AreEqual(15, treeFragments[1].Count); Assert.AreEqual(1, treeFragments[2].Count); } } }
public void Test_ExcelExporter() { BaseWindowStub baseWin = new BaseWindowStub(); GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; baseWin.Context.ShieldState = ShieldState.None; Assert.Throws(typeof(ArgumentNullException), () => { new ExcelExporter(null); }); using (ExcelExporter exporter = new ExcelExporter(baseWin)) { } }
public void Test_PedigreeExporter() { BaseWindowStub baseWin = new BaseWindowStub(); GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; baseWin.Context.ShieldState = ShieldState.None; Assert.Throws(typeof(ArgumentNullException), () => { new PedigreeExporter(null, null); }); using (PedigreeExporter exporter = new PedigreeExporter(baseWin, iRec)) { exporter.Options = GlobalOptions.Instance; Assert.IsNotNull(exporter.Options); Assert.AreEqual(iRec, exporter.Root); Assert.AreEqual(ShieldState.None, exporter.ShieldState); exporter.Options.PedigreeOptions.IncludeAttributes = true; exporter.Options.PedigreeOptions.IncludeNotes = true; exporter.Options.PedigreeOptions.IncludeSources = true; exporter.Options.PedigreeOptions.IncludeGenerations = true; exporter.Kind = PedigreeExporter.PedigreeKind.Descend_Konovalov; Assert.AreEqual(PedigreeExporter.PedigreeKind.Descend_Konovalov, exporter.Kind); var writer = Substitute.For <CustomWriter>(); exporter.Options.PedigreeOptions.Format = PedigreeFormat.Excess; Assert.IsTrue(exporter.Generate(writer)); exporter.Options.PedigreeOptions.Format = PedigreeFormat.Compact; Assert.IsTrue(exporter.Generate(writer)); exporter.Kind = PedigreeExporter.PedigreeKind.Descend_dAboville; exporter.Options.PedigreeOptions.Format = PedigreeFormat.Excess; Assert.IsTrue(exporter.Generate(writer)); exporter.Kind = PedigreeExporter.PedigreeKind.Ascend; exporter.Options.PedigreeOptions.Format = PedigreeFormat.Excess; Assert.IsTrue(exporter.Generate(writer)); } }
public void Test_MergeRecord_Fam() { using (var ctx1 = new BaseContext(null)) { IBaseWindow baseWin = new BaseWindowStub(ctx1); using (Stream stmGed1 = TestUtils.LoadResourceStream("test_mergerec.ged")) { var gedcomProvider = new GEDCOMProvider(ctx1.Tree); gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1); } GDMFamilyRecord famRec1 = ctx1.Tree.XRefIndex_Find("F1") as GDMFamilyRecord; Assert.IsNotNull(famRec1); GDMFamilyRecord famRec2 = ctx1.Tree.XRefIndex_Find("F2") as GDMFamilyRecord; Assert.IsNotNull(famRec2); TreeTools.MergeRecord(baseWin, famRec1, famRec2, true); } }
public void Test_MergeTree_SelfTest() { using (var ctx1 = new BaseContext(null)) { IBaseWindow baseWin = new BaseWindowStub(ctx1); using (Stream stmGed1 = TestUtils.LoadResourceStream("test1.ged")) { var gedcomProvider = new GEDCOMProvider(ctx1.Tree); gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1); } using (var ctx2 = new BaseContext(null)) { using (Stream stmGed2 = TestUtils.LoadResourceStream("test2.ged")) { var gedcomProvider = new GEDCOMProvider(ctx2.Tree); gedcomProvider.LoadFromStreamExt(stmGed2, stmGed2); } TreeTools.MergeTree(ctx1.Tree, ctx2.Tree, null, true); } } }
public void Test_MergeRecord_Indi() { Assembly assembly = typeof(CoreTests).Assembly; using (var ctx1 = new BaseContext(null)) { IBaseWindow baseWin = new BaseWindowStub(ctx1); using (Stream stmGed1 = assembly.GetManifestResourceStream("GKTests.Resources.test_mergerec.ged")) { var gedcomProvider = new GEDCOMProvider(ctx1.Tree); gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1); } GDMIndividualRecord iRec1 = ctx1.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; Assert.IsNotNull(iRec1); GDMIndividualRecord iRec2 = ctx1.Tree.XRefIndex_Find("I4") as GDMIndividualRecord; Assert.IsNotNull(iRec2); TreeTools.MergeRecord(baseWin, iRec1, iRec2, true); } }
public void Test_MergeTree_SelfTest() { Assembly assembly = typeof(CoreTests).Assembly; using (var ctx1 = new BaseContext(null)) { IBaseWindow baseWin = new BaseWindowStub(ctx1); using (Stream stmGed1 = assembly.GetManifestResourceStream("GKTests.Resources.test1.ged")) { var gedcomProvider = new GEDCOMProvider(ctx1.Tree); gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1); } using (var ctx2 = new BaseContext(null)) { using (Stream stmGed2 = assembly.GetManifestResourceStream("GKTests.Resources.test2.ged")) { var gedcomProvider = new GEDCOMProvider(ctx2.Tree); gedcomProvider.LoadFromStreamExt(stmGed2, stmGed2); } TreeTools.MergeTree(ctx1.Tree, ctx2.Tree, null, true); } } }