Skip to content

Commit

Permalink
Add support for custom records on event records.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtx500 committed Dec 28, 2023
1 parent 673fe16 commit 2276dab
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
20 changes: 20 additions & 0 deletions GeneGenie.Gedcom.Tests/Data/UidAndBurg.ged
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
0 HEAD
1 SOUR PhpGedView
2 NAME PhpGedView Online Genealogy
2 VERS 3.3.8 final
1 DATE 1 Apr 2006
0 @I1@ INDI
1 _UID A5A812A4C0FE44C9A98F8D4627073B69AB88
1 NAME TestGivenName /TestSurname/
2 SURN TestSurname
2 GIVN TestGivenName
1 SEX M
1 BIRT
2 DATE 9 OCT 1990
2 _BURG unbekannt
1 CHAN
2 DATE 28 DEC 2023
3 TIME 11:21:46
0 @SUBM@ SUBM
1 NAME Test for GeneGenie
0 TRLR
3 changes: 3 additions & 0 deletions GeneGenie.Gedcom.Tests/GeneGenie.Gedcom.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
<None Update="Data\SubmitterReference.ged">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Data\UidAndBurg.ged">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<PropertyGroup>
Expand Down
46 changes: 46 additions & 0 deletions GeneGenie.Gedcom.Tests/RecordReaderTests/GecomCustomRecordTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// <copyright file="GedcomCustomRecordTest.cs" company="GeneGenie.com">
// Copyright (c) GeneGenie.com. All Rights Reserved.
// Licensed under the GNU Affero General Public License v3.0. See LICENSE in the project root for license information.
// </copyright>
// <author> Copyright (C) 2023 Herbert Oppmann [email protected] </author>


namespace GeneGenie.Gedcom.Tests.RecordReaderTests
{
using GeneGenie.Gedcom.Parser;
using System;
using Xunit;

/// <summary>
/// Tests to ensure that custom records are correctly read in.
/// </summary>
public class GedcomCustomRecordTest
{
/// <summary>
/// Test for custom record '_UID' in individual record.
/// </summary>
[Fact]
public void Record_UID()
{
var reader = GedcomRecordReader.CreateReader("./Data/UidAndBurg.ged");
GedcomIndividualRecord indi = reader.Database.Individuals[0];
GedcomCustomRecord cr = indi.Custom[0];
Assert.Equal("_UID", cr.Tag);
Assert.Equal("A5A812A4C0FE44C9A98F8D4627073B69AB88", cr.Classification);
}

/// <summary>
/// Test for custom record '_BURG' in event record.
/// </summary>
[Fact]
public void Record_BURG()
{
var reader = GedcomRecordReader.CreateReader("./Data/UidAndBurg.ged");
GedcomIndividualRecord indi = reader.Database.Individuals[0];
GedcomEvent er = indi.Events[0];
GedcomCustomRecord cr = er.Custom[0];
Assert.Equal("_BURG", cr.Tag);
Assert.Equal("unbekannt", cr.Classification);
}
}
}
3 changes: 3 additions & 0 deletions GeneGenie.Gedcom/GedcomEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ public override GedcomRecordType RecordType
get { return GedcomRecordType.Event; }
}

/// <summary>Gets or sets the list of <see cref="GedcomCustomRecord"/> entries found when parsing an event.</summary>
public GedcomRecordList<GedcomCustomRecord> Custom { get; set; } = new GedcomRecordList<GedcomCustomRecord>();

/// <summary>
/// Gets the gedcom tag.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion GeneGenie.Gedcom/Parser/GedcomRecordReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3807,7 +3807,7 @@ private void ReadEventRecord()
custom.Classification = lineValue;
}

// TODO: may want to use customs at some point
eventRecord.Custom.Add(custom);
parseState.Records.Push(custom);
break;
}
Expand Down

0 comments on commit 2276dab

Please sign in to comment.