Skip to content

Commit

Permalink
Infrastructure Genealogy module
Browse files Browse the repository at this point in the history
  • Loading branch information
JoergHoffmannatGitHub committed Nov 24, 2024
1 parent e426efa commit 8309bef
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 11 deletions.
11 changes: 1 addition & 10 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>5.0.1</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
<Product>Family.Show</Product>
<Copyright>© $([System.DateTime]::Now.ToString('yyyy'))</Copyright>
<RepositoryUrl>https://github.com/JoergHoffmannatGitHub/Family.Show</RepositoryUrl>
Expand All @@ -10,14 +10,5 @@
<!-- Versioning projects -->
<PropertyGroup>
<TargetFrameworkVersion>net8.0</TargetFrameworkVersion>
<MicrosoftWindowsAPICodePackShellVersion>1.1.5</MicrosoftWindowsAPICodePackShellVersion>
<!-- Tests -->
<CoverletCollectorVerion>6.0.2</CoverletCollectorVerion>
<CoverletMsbuildrVerion>6.0.2</CoverletMsbuildrVerion>
<GitHubActionsTestLoggerVersion>2.4.1</GitHubActionsTestLoggerVersion>
<MicrosoftNETTestSdkVerion>17.11.1</MicrosoftNETTestSdkVerion>
<XunitVerion>2.9.2</XunitVerion>
<XunitRunnerVisualstudioVerion>2.8.2</XunitRunnerVisualstudioVerion>
<XunitStaFactVerion>1.1.11</XunitStaFactVerion>
</PropertyGroup>
</Project>
26 changes: 26 additions & 0 deletions FamilyShow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FamilyShowLib.Tests", "Fami
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FamilyShow.Tests", "FamilyShow.Tests\FamilyShow.Tests.csproj", "{0F6BE0B3-C648-4B57-8286-BD9346562CE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{2CD5FF4E-7AF0-4A59-98FC-8114B4D060F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genealogy", "Package\Genealogy\Genealogy.csproj", "{D1FF5FB4-625C-45B0-B904-86DD69A11952}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genealogy.Tests", "Package\Genealogy.Tests\Genealogy.Tests.csproj", "{D946C8EF-83FC-4E0B-8434-F148D010A68F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package Items", "Package Items", "{C4DCA96D-8C25-4FCB-9C5E-5E2ECBC93529}"
ProjectSection(SolutionItems) = preProject
Package\Directory.Build.props = Package\Directory.Build.props
Package\Directory.Build.targets = Package\Directory.Build.targets
Package\Genealogy.snk = Package\Genealogy.snk
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -41,10 +54,23 @@ Global
{0F6BE0B3-C648-4B57-8286-BD9346562CE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F6BE0B3-C648-4B57-8286-BD9346562CE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F6BE0B3-C648-4B57-8286-BD9346562CE3}.Release|Any CPU.Build.0 = Release|Any CPU
{D1FF5FB4-625C-45B0-B904-86DD69A11952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1FF5FB4-625C-45B0-B904-86DD69A11952}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1FF5FB4-625C-45B0-B904-86DD69A11952}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1FF5FB4-625C-45B0-B904-86DD69A11952}.Release|Any CPU.Build.0 = Release|Any CPU
{D946C8EF-83FC-4E0B-8434-F148D010A68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D946C8EF-83FC-4E0B-8434-F148D010A68F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D946C8EF-83FC-4E0B-8434-F148D010A68F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D946C8EF-83FC-4E0B-8434-F148D010A68F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D1FF5FB4-625C-45B0-B904-86DD69A11952} = {2CD5FF4E-7AF0-4A59-98FC-8114B4D060F0}
{D946C8EF-83FC-4E0B-8434-F148D010A68F} = {2CD5FF4E-7AF0-4A59-98FC-8114B4D060F0}
{C4DCA96D-8C25-4FCB-9C5E-5E2ECBC93529} = {2CD5FF4E-7AF0-4A59-98FC-8114B4D060F0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {14954E03-1F04-4E4C-BF00-2F16BD8030DA}
EndGlobalSection
Expand Down
11 changes: 11 additions & 0 deletions Package/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Genealogy.snk</AssemblyOriginatorKeyFile>
<PublicKey>
00240000048000009400000006020000002400005253413100040000010001001919901f5df15129968f4c9323fe7d78773579b041f0cefd2f39d406133417c48e6c790381da7d59a51eb3b8b8844fddb6b480a1ab2a630d3f998b6f44c67d67ee94f0c7a7372d071fd47e602ed30be383ba07fce60f0a075935ae637ceca75e9179431eaed5bd3b14d7b50d8f3587902f07b5a78f7ab705370f937dc542bcbc
</PublicKey>
<PublicKeyToken>d55723e43f351317</PublicKeyToken>
</PropertyGroup>
</Project>
28 changes: 28 additions & 0 deletions Package/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project>
<!-- found in https://www.meziantou.net/declaring-internalsvisibleto-in-the-csproj.htm -->
<Target Name="AddInternalsVisibleTo" BeforeTargets="BeforeCompile">
<!-- Add default suffix if there is no InternalsVisibleTo or InternalsVisibleToSuffix defined -->
<ItemGroup Condition="@(InternalsVisibleToSuffix->Count()) == 0 AND @(InternalsVisibleTo->Count()) == 0">
<InternalsVisibleToSuffix Include=".Tests, PublicKey=$(PublicKey)" />
</ItemGroup>

<!-- Handle InternalsVisibleTo -->
<!-- <InternalsVisibleTo Include="CustomTest1" /> [assembly: InternalsVisibleTo("CustomTest1")] -->
<!-- <InternalsVisibleTo Include="CustomTest2, PublicKey=abc" /> [assembly: InternalsVisibleTo("CustomTest2, PublicKey=abc")] -->
<!-- <InternalsVisibleTo Include="$(AssemblyName).Custom" /> [assembly: InternalsVisibleTo("ClassLibrary1.Custom")] -->
<ItemGroup Condition="'@(InternalsVisibleTo->Count())' &gt; 0">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<!-- Handle InternalsVisibleToSuffix -->
<!-- <InternalsVisibleToSuffix Include=".Tests" /> [assembly: InternalsVisibleTo("ClassLibrary1.Tests")] -->
<!-- <InternalsVisibleToSuffix Include=".FunctionalTests" /> [assembly: InternalsVisibleTo("ClassLibrary1.FunctionalTests")] -->
<ItemGroup Condition="@(InternalsVisibleToSuffix->Count()) &gt; 0">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(AssemblyName)%(InternalsVisibleToSuffix.Identity)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
</Project>
47 changes: 47 additions & 0 deletions Package/Genealogy.Tests/DateTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Genealogy;

using static System.Runtime.InteropServices.JavaScript.JSType;

namespace Genealogy.Tests;

public class DateTest
{
public static readonly TheoryData<string> ValidGedcomDates =
[
"6 MAY 2001",
"1977",
"BET 1982 AND 1984",
"EST 1752",
"ABT JAN 1781",
"AFT JAN 1781",
"BEF JAN 1781",
"FROM 1670 TO 1800",
"FROM 1670 TO JULIAN 1800",
"FROM JULIAN 1670 TO 1800",
];

[Theory, MemberData(nameof(ValidGedcomDates))]
public void ParseTest(string date)
{
// Arrange
// Act
IDate result = Date.Parse(date);
// Assert
Assert.Equal(date, result.ToGedcom());
}

public static readonly TheoryData<string> InvalidGedcomDates =
[
null,
string.Empty,
"123",
];

[Theory, MemberData(nameof(InvalidGedcomDates))]
public void ParseThrowsGenealogyException(string date)
{
// Arrange
// Act & Assert
Assert.Throws<GenealogyException>(() => Date.Parse(date));
}
}
29 changes: 29 additions & 0 deletions Package/Genealogy.Tests/Genealogy.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="coverlet.msbuild" />
<PackageReference Include="GitHubActionsTestLogger" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Genealogy\Genealogy.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

</Project>
Binary file added Package/Genealogy.snk
Binary file not shown.
25 changes: 25 additions & 0 deletions Package/Genealogy/Date.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Genealogy.DateImplementation;

namespace Genealogy
{
public class Date
{
/// <summary>
/// Parses the specified formal date string representing a GEDCOM date of any kind.
/// </summary>
/// <param name="date">The formal date string to parse.</param>
/// <returns>A new instance defining interface <see cref="IDate"/></returns>
/// <exception cref="GenealogyException">
/// Throw if the formal date string is null or empty.
/// </exception>
public static IDate Parse(string date)
{
if (string.IsNullOrEmpty(date))
{
throw new GenealogyException("Invalid Date");
}

return new SimpleDate(date);
}
}
}
35 changes: 35 additions & 0 deletions Package/Genealogy/DateImplementation/SimpleDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;

namespace Genealogy.DateImplementation
{
internal class SimpleDate : IDate
{
private string _date;

/// <summary>
/// Initializes a new instance of the <see cref="SimpleDate"/> class.
/// </summary>
/// <param name="date">The formal date string that describes a simple GEDCOM date.</param>
internal SimpleDate(string date)
{
ParseDate(date);
}

public string ToGedcom()
{
return _date;
}

private void ParseDate(string date)
{
// There is a minimum length of 4 characters
if (date.Length < 4)
{
throw new GenealogyException("Invalid Date: Must have at least YYYY");
}

_date = date;
}
}
}
7 changes: 7 additions & 0 deletions Package/Genealogy/Genealogy.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
17 changes: 17 additions & 0 deletions Package/Genealogy/GenealogyException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;

namespace Genealogy
{
public class GenealogyException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="GenealogyException"/> class.
/// message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public GenealogyException(string message)
: base(message)
{
}
}
}
9 changes: 9 additions & 0 deletions Package/Genealogy/IDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Genealogy
{
public interface IDate
{
string ToGedcom();
}
}
Binary file added Package/public.snk
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The aim of this project is the enhancement with actual technologies:

### Requirements

Family.Show runs on Microsoft Windows 10. To run the application on Microsoft Windows without .NET 8, you must first download and install version 8.0 of .NET 8. The framework can be downloaded at https://dotnet.microsoft.com/en-us/download/dotnet/8.0.
Family.Show runs on Microsoft Windows 10 or higher. To run the application on Microsoft Windows without .NET 8, you must first download and install version 8.0 of .NET 8. The framework can be downloaded at https://dotnet.microsoft.com/en-us/download/dotnet/8.0.

## Example

Expand Down

0 comments on commit 8309bef

Please sign in to comment.