Skip to content

Commit

Permalink
Issue 2 (#44)
Browse files Browse the repository at this point in the history
* Empty test class and test data for spouse sealing.

* New (obscure) record type can now be imported / exported (LDS Spouse Sealing)
Closes #2

* Tidy up copyright notices.

* Fix missing repo record from GEDCOM test file for #2.

* Add missing equivalence checks for GedcomAddress.

* Rename spouse sealing test data to split out for issue #42.
Include spouse sealing in record rewriter tests for #2.
Split new test file out for child pedigree for #43.
  • Loading branch information
RyanONeill1970 authored Mar 6, 2017
1 parent 57d4655 commit 30e0b3b
Show file tree
Hide file tree
Showing 18 changed files with 1,151 additions and 21 deletions.
98 changes: 96 additions & 2 deletions GeneGenie.Gedcom.Parser/GedcomRecordReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,9 @@ private void Parser_TagFound(object sender, EventArgs e)
case GedcomRecordType.SourceCitation:
ReadSourceCitationRecord();
break;
case GedcomRecordType.SpouseSealing:
ReadSpouseSealingRecord();
break;
case GedcomRecordType.FamilyLink:
ReadFamilyLinkRecord();
break;
Expand Down Expand Up @@ -1595,8 +1598,12 @@ private void ReadFamilyRecord()
}

break;
case "FIXME?????": // TODO:
// lds spouse sealing
case "SLGS": // LDS spouse sealing.
familyRecord.SpouseSealing = new GedcomSpouseSealingRecord();
familyRecord.SpouseSealing.Description = lineValue;
familyRecord.SpouseSealing.Level = level;
parseState.Records.Push(familyRecord.SpouseSealing);

break;
case "REFN":
if (lineValueType == GedcomLineValueType.DataType)
Expand Down Expand Up @@ -4410,6 +4417,93 @@ private void ReadSourceCitationRecord()
}
}

private void ReadSpouseSealingRecord()
{
var record = parseState.Records.Peek() as GedcomSpouseSealingRecord;

if (level == record.ParsingLevel + 1)
{
switch (tag)
{
case "DATE":
GedcomDate date = new GedcomDate(Database);
date.Level = level;
parseState.Records.Push(date);
record.Date = date;
level++;
ReadDateRecord();
level--;
parseState.Records.Pop();
break;
case "PLAC":
record.Place = new GedcomPlace();
record.Place.Database = Database;
record.Place.Level = level;

if (lineValueType == GedcomLineValueType.DataType)
{
record.Place.Name = Database.PlaceNameCollection[lineValue];
}
else
{
// invalid, provide a name anyway
record.Place.Name = "Unknown";
Debug.WriteLine("invalid place node, no name at level: " + level);
}

break;
case "NOTE":
AddNoteRecord(record);
break;
case "SOUR":
AddSourceCitation(record);
break;
case "STAT":
if (lineValueType == GedcomLineValueType.DataType)
{
try
{
record.Status = EnumHelper.Parse<SpouseSealingDateStatus>(lineValue, true);
}
catch
{
Debug.WriteLine("Invalid spouse sealing date status value: " + lineValue);

record.Status = SpouseSealingDateStatus.NotSet;
}
}

break;
case "TEMP":
record.TempleCode = lineValue;
break;
default:
// TODO: Log unexpected tag below sealing.
break;
}
}
else if ((!string.IsNullOrEmpty(parseState.PreviousTag)) &&
parseState.PreviousTag == "STAT" &&
level == parseState.PreviousLevel + 1)
{
if (tag == "DATE")
{
if (lineValueType == GedcomLineValueType.DataType)
{
record.StatusChangeDate = new GedcomChangeDate(Database);
record.StatusChangeDate.ParseDateString(lineValue);
record.StatusChangeDate.Level = level;
parseState.Records.Push(record.StatusChangeDate);
}
}
}
else
{
// shouldn't be here
Debug.WriteLine("Unknown state / tag parsing note node: " + tag + "\t at level: " + level);
}
}

private void ReadFamilyLinkRecord()
{
GedcomFamilyLink childOf;
Expand Down
41 changes: 41 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/Child-sealing.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
0 HEAD
1 SOUR FTM
2 VERS Family Tree Maker (22.0.0.1404)
2 NAME Family Tree Maker for Windows
2 CORP Ancestry.com
3 ADDR 360 W 4800 N
4 CONT Provo, UT 84604
3 PHON (801) 705-7000
1 DEST GED55
1 DATE 21 OCT 2016
1 CHAR UTF-8
1 FILE C:\Users\r\Desktop\Sealing test_2016-10-21.ged
1 SUBM @SUBM@
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
0 @SUBM@ SUBM
0 @I1@ INDI
1 NAME /Child/
1 SEX U
1 SLGC Sealed to parents description
2 DATE 02 FEB 2010
2 PLAC Alaska, San Jose, Costa Rica
1 FAMC @F1@
0 @I2@ INDI
1 NAME /Father/
1 SEX M
1 TITL Father
1 FAMS @F1@
0 @I3@ INDI
1 NAME /Mother/
1 SEX F
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I3@
1 CHIL @I1@
2 _FREL Natural
2 _MREL Natural

0 TRLR
42 changes: 42 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/FTM-pedigree-mapping.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
0 HEAD
1 SOUR FTM
2 VERS Family Tree Maker (22.0.0.1404)
2 NAME Family Tree Maker for Windows
2 CORP Ancestry.com
3 ADDR 360 W 4800 N
4 CONT Provo, UT 84604
3 PHON (801) 705-7000
1 DEST GED55
1 DATE 21 OCT 2016
1 CHAR UTF-8
1 SUBM @SUBM@
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED

0 @SUBM@ SUBM

0 @I1@ INDI
1 NAME /Child/
1 SEX U
1 FAMC @F1@

0 @I2@ INDI
1 NAME /Father/
1 SEX M
1 TITL Father
1 FAMS @F1@

0 @I3@ INDI
1 NAME /Mother/
1 SEX F
1 FAMS @F1@

0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I3@
1 CHIL @I1@
2 _FREL Natural
2 _MREL Natural

0 TRLR
66 changes: 66 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/Sealing-test_2016-10-21.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
0 HEAD
1 SOUR FTM
2 VERS Family Tree Maker (22.0.0.1404)
2 NAME Family Tree Maker for Windows
2 CORP Ancestry.com
3 ADDR 360 W 4800 N
4 CONT Provo, UT 84604
3 PHON (801) 705-7000
1 DEST GED55
1 DATE 21 OCT 2016
1 CHAR UTF-8
1 FILE C:\Users\r\Desktop\Sealing test_2016-10-21.ged
1 SUBM @SUBM@
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
0 @SUBM@ SUBM
0 @I1@ INDI
1 NAME /Child/
1 SEX U
1 SLGC Sealed to parents description
2 DATE 02 FEB 2010
2 PLAC Alaska, San Jose, Costa Rica
1 FAMC @F1@
0 @I2@ INDI
1 NAME /Father/
1 SEX M
1 TITL Father
1 FAMS @F1@
0 @I3@ INDI
1 NAME /Mother/
1 SEX F
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I3@
1 CHIL @I1@
2 _FREL Natural
2 _MREL Natural
1 SLGS Sealing description
2 DATE 10 JAN 2011
2 PLAC Timbuktu
2 TEMP Temple Code
2 STAT DNS/CAN
3 DATE 11 FEB 2012
2 SOUR @SRC1@
2 NOTE An example note

0 @SRC1@ SOUR
1 REPO @R150224420@
1 RFN Source 1 reference
1 TITL Source 1
1 AUTH Source 1 author
1 PUBL Source 1 publisher
1 CALN 11111111111
1 NOTE Note for source

0 @R150224420@ REPO
1 RFN Reference
1 NAME Repository 1
1 PHON 12112121212
1 ADDR Bedfordshire
1 CALN 1
1 NOTE Note

0 TRLR
61 changes: 61 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/Spouse-sealing.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
0 HEAD
1 SOUR FTM
2 VERS Family Tree Maker (22.0.0.1404)
2 NAME Family Tree Maker for Windows
2 CORP Ancestry.com
3 ADDR 360 W 4800 N
4 CONT Provo, UT 84604
3 PHON (801) 705-7000
1 DEST GED55
1 DATE 21 OCT 2016
1 CHAR UTF-8
1 FILE C:\Users\r\Desktop\Sealing test_2016-10-21.ged
1 SUBM @SUBM@
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
0 @SUBM@ SUBM
0 @I1@ INDI
1 NAME /Child/
1 SEX U
1 FAMC @F1@
0 @I2@ INDI
1 NAME /Father/
1 SEX M
1 TITL Father
1 FAMS @F1@
0 @I3@ INDI
1 NAME /Mother/
1 SEX F
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I3@
1 CHIL @I1@
1 SLGS Sealing description
2 DATE 10 JAN 2011
2 PLAC Timbuktu
2 TEMP Temple Code
2 STAT DNS/CAN
3 DATE 11 FEB 2012
2 SOUR @SRC1@
2 NOTE An example note

0 @SRC1@ SOUR
1 REPO @R150224420@
1 RFN Source 1 reference
1 TITL Source 1
1 AUTH Source 1 author
1 PUBL Source 1 publisher
1 CALN 11111111111
1 NOTE Note for source

0 @R150224420@ REPO
1 RFN Reference
1 NAME Repository 1
1 PHON 12112121212
1 ADDR Bedfordshire
1 CALN 1
1 NOTE Note

0 TRLR
7 changes: 6 additions & 1 deletion GeneGenie.Gedcom.Tests/GedcomRecordWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
// </copyright>
// <author> Copyright (C) 2007 David A Knight [email protected] </author>
// <author> Copyright (C) 2016 Ryan O'Neill [email protected] </author>
// <author> Copyright (C) 2017 Ryan O'Neill [email protected] </author>

namespace GeneGenie.Gedcom.Parser
{
Expand All @@ -41,6 +41,7 @@ public GedcomRecordWriterTest(ITestOutputHelper output)

[Theory]
[InlineData(".\\Data\\presidents.ged")]
[InlineData(".\\Data\\Spouse-sealing.ged")]
[InlineData(".\\Data\\superfluous-ident-test.ged")]
private void Gedcom_databases_are_equal_after_rewriting(string sourceFile)
{
Expand All @@ -50,11 +51,13 @@ private void Gedcom_databases_are_equal_after_rewriting(string sourceFile)

var rewrittenReader = GedcomRecordReader.CreateReader(rewrittenPath);

AttachFileContentsToTest(sourceFile, rewrittenPath);
Assert.Equal(originalReader.Database, rewrittenReader.Database);
}

[Theory]
[InlineData(".\\Data\\presidents.ged")]
[InlineData(".\\Data\\Spouse-sealing.ged")]
[InlineData(".\\Data\\superfluous-ident-test.ged")]
private void Gedcom_headers_are_equal_after_rewriting(string sourceFile)
{
Expand All @@ -64,11 +67,13 @@ private void Gedcom_headers_are_equal_after_rewriting(string sourceFile)

var rewrittenReader = GedcomRecordReader.CreateReader(rewrittenPath);

AttachFileContentsToTest(sourceFile, rewrittenPath);
Assert.Equal(originalReader.Database.Header, rewrittenReader.Database.Header);
}

[Theory]
[InlineData(".\\Data\\presidents.ged")]
[InlineData(".\\Data\\Spouse-sealing.ged")]
[InlineData(".\\Data\\superfluous-ident-test.ged")]
private void Individuals_are_equal_after_rewriting(string sourceFile)
{
Expand Down
Loading

0 comments on commit 30e0b3b

Please sign in to comment.